generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Debug

Previous Thread :: Next Thread 
iMario1207xOtherUser is not online. iMario1207xOtherUser
Joined: 31 Jul 2011
Total Posts: 81
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
iMario1207xOtherUser is not online. iMario1207xOtherUser
Joined: 31 Jul 2011
Total Posts: 81
15 Aug 2012 04:04 PM
I'll give credit if it works, I promise.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
15 Aug 2012 04:05 PM
Hm, when do you call the function?

† KMXD †
Report Abuse
iMario1207xOtherUser is not online. iMario1207xOtherUser
Joined: 31 Jul 2011
Total Posts: 81
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
iMario1207xOtherUser is not online. iMario1207xOtherUser
Joined: 31 Jul 2011
Total Posts: 81
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
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
15 Aug 2012 04:07 PM
@KM It's not his script in the first place. Anyway we want the whole script.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
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 is not online. 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
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
15 Aug 2012 04:08 PM
Wow. The problem is you aren't loading it.... It saves, but you never load it.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
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
iMario1207xOtherUser is not online. iMario1207xOtherUser
Joined: 31 Jul 2011
Total Posts: 81
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
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
15 Aug 2012 04:09 PM
He still needs to load it.
Report Abuse
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
15 Aug 2012 04:10 PM
@Mario no, use the old one. Also add a load.
Report Abuse
ShoeBox4 is not online. 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
iMario1207xOtherUser is not online. iMario1207xOtherUser
Joined: 31 Jul 2011
Total Posts: 81
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
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
15 Aug 2012 04:11 PM
No, you make a new function.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
15 Aug 2012 04:11 PM
Using :LoadNumber.

† KMXD †
Report Abuse
ShoeBox4 is not online. 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
iMario1207xOtherUser is not online. iMario1207xOtherUser
Joined: 31 Jul 2011
Total Posts: 81
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
18cwatford is not online. 18cwatford
Joined: 08 Oct 2009
Total Posts: 5410
15 Aug 2012 04:15 PM
Nope.
Report Abuse
iMario1207xOtherUser is not online. iMario1207xOtherUser
Joined: 31 Jul 2011
Total Posts: 81
15 Aug 2012 04:15 PM
Okay KN, I just saw your post.
Report Abuse
iMario1207xOtherUser is not online. iMario1207xOtherUser
Joined: 31 Jul 2011
Total Posts: 81
15 Aug 2012 04:17 PM
Can you post the load script here?
Report Abuse
ShoeBox4 is not online. 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 is not online. 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
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image