|
| 15 Aug 2012 03:55 PM |
Hi, I got a script and it doesn't seem to work, it is a script to save my RPG game, EXP, level, and gold. Can you guys try to debug it, or see what is the problem?
function SaveDataz(plyr) local xp, lvl, gold = plyr.leaderstats.EXP, plyr.leaderstats.Level, plyr.leaderstats.Gold plyr:WaitForDataReady() --guess what that means plyr:SaveNumber("EXP", xp.Value) plyr:SaveNumber("Level", lvl.Value) plyr:SaveNumber("Gold", gold.Value) --Saves those values under obvious keywords end |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:04 PM |
| I'll give credit if it works, I promise. |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:05 PM |
Hm, when do you call the function?
† KMXD † |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:06 PM |
| I want it to auto save when a player leaves, is there any problem with the script? |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:07 PM |
I forgot to paste the whole script.
function SaveDataz(plyr) local xp, lvl, gold = plyr.leaderstats.EXP, plyr.leaderstats.Level, plyr.leaderstats.Gold plyr:WaitForDataReady() --guess what that means plyr:SaveNumber("EXP", xp.Value) plyr:SaveNumber("Level", lvl.Value) plyr:SaveNumber("Gold", gold.Value) --Saves those values under obvious keywords end
game.Players.PlayerLeaving:connect(SaveDataz)
Is there anything wrong with it? When I leave and come back, the level doesn't save. |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:07 PM |
| @KM It's not his script in the first place. Anyway we want the whole script. |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:07 PM |
Well you'd use a .PlayerRemoving event then, if you just put the above code, it was never called.
† KMXD † |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 15 Aug 2012 04:07 PM |
game.Players.PlayerRemoving:connect(function(player) SaveDataz(player.Name) end)
Add that to the end of your script. |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:08 PM |
| Wow. The problem is you aren't loading it.... It saves, but you never load it. |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:08 PM |
function SaveDataz(plyr) local xp, lvl, gold = plyr.leaderstats.EXP, plyr.leaderstats.Level, plyr.leaderstats.Gold plyr:WaitForDataReady() --guess what that means plyr:SaveNumber("EXP", xp.Value) plyr:SaveNumber("Level", lvl.Value) plyr:SaveNumber("Gold", gold.Value) --Saves those values under obvious keywords end game.Players.PlayerRemoving:connect(SaveDataz)
† KMXD † |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:09 PM |
Is this right?
function SaveDataz(plyr) local xp, lvl, gold = plyr.leaderstats.EXP, plyr.leaderstats.Level, plyr.leaderstats.Gold plyr:WaitForDataReady() --guess what that means plyr:SaveNumber("EXP", xp.Value) plyr:SaveNumber("Level", lvl.Value) plyr:SaveNumber("Gold", gold.Value) --Saves those values under obvious keywords end
game.Players.PlayerRemoving:connect(function(player) SaveDataz(player.Name) end)
|
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:09 PM |
| He still needs to load it. |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:10 PM |
| @Mario no, use the old one. Also add a load. |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 15 Aug 2012 04:11 PM |
| Ya, use the old one :P I made a late post. Plus I was just wrong, even thought it should work, other one is better. |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:11 PM |
I'm not really good at scripting,
so for the load script,
do I change function SaveDataz(plyr)
to function LoadDataz(plyr) |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:11 PM |
| No, you make a new function. |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:11 PM |
Using :LoadNumber.
† KMXD † |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 15 Aug 2012 04:12 PM |
Make a seperate function for loading it. Then add your loading connection line.
game.Players.PlayerAdded:connect(LoadDataz) |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:14 PM |
I'm a little confused.. so is this the Load Script?
function SaveDataz(plyr) local xp, lvl, gold = plyr.leaderstats.EXP, plyr.leaderstats.Level, plyr.leaderstats.Gold plyr:WaitForDataReady() --guess what that means plyr:SaveNumber("EXP", xp.Value) plyr:SaveNumber("Level", lvl.Value) plyr:SaveNumber("Gold", gold.Value) --Saves those values under obvious keywords end game.Players.PlayerAdded:connect(LoadDataz) |
|
|
| Report Abuse |
|
|
| |
|
|
| 15 Aug 2012 04:15 PM |
| Okay KN, I just saw your post. |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:17 PM |
| Can you post the load script here? |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 15 Aug 2012 04:18 PM |
That is your save function. Change the connection line at the bottom of that function to the old one. Add this to the bottom of your script to load it:
function LoadDataz(plyr) plyr:WaitForDataReady() local xp, lvl, gold = plyr.leaderstats.EXP, plyr.leaderstats.Level, plyr.leaderstats.Gold plyr:LoadNumber("EXP", xp.Value) plyr:LoadNumber("Level", lvl.Value) plyr:LoadNumber("Gold", gold.Value) end game.Players.PlayerAdded:connect(function(LoadDataz) |
|
|
| Report Abuse |
|
|
ShoeBox4
|
  |
| Joined: 06 Apr 2011 |
| Total Posts: 890 |
|
|
| 15 Aug 2012 04:19 PM |
Correction for my above script:
Change the last line to
game.Players.PlayerAdded:connect(LoadDataz) |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2012 04:20 PM |
@Shoe
That won't work.
I suggest combining these script with your leaderboard to avoid any errors.
† KMXD † |
|
|
| Report Abuse |
|
|