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 » Scripters
Home Search
 

Re: Can anyone-

Previous Thread :: Next Thread 
zaniac10 is not online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
17 Mar 2016 03:07 AM
-help me make a script to save the leaderstat "Value" in all players who leave the game?

All I got is...

||||||||||||||

local ds = game:GetService("DataStoreService"):GetDataStore("Level")

game.Players.PlayerAdded:connect(function(plr)
local ls = plr:WaitForChild("leaderstats")
local lvl = ls:FindFirstChild("Level")

lvl = ds:GetAsync("Level")
end)

game.Players.PlayerRemoving:connect(function(plrr)
ds:UpdateAsync("Level")
end)

||||||||||||||

..and obviously, that didn't work. So what can I do?


Report Abuse
zaniac10 is not online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
17 Mar 2016 04:54 AM
b


Report Abuse
zaniac10 is not online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
17 Mar 2016 05:45 AM
bumop


Report Abuse
zaniac10 is not online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
17 Mar 2016 07:23 PM
bump
Report Abuse
lululukas is not online. lululukas
Joined: 23 Aug 2010
Total Posts: 1043
17 Mar 2016 07:50 PM
you need a key with the playerId

key="Player-"..plr.userId

savedvalues=ds:GetAsync(key)

if savedvalues then

lvl.Value=savedvalues[1]

Report Abuse
zaniac10 is not online. zaniac10
Joined: 18 Aug 2009
Total Posts: 10000
17 Mar 2016 09:31 PM
so I tried this...

local ds = game:GetService("DataStoreService"):GetDataStore("Level")

game.Players.PlayerAdded:connect(function(plr)
local ls = plr:WaitForChild("leaderstats")
local lvl = ls:FindFirstChild("Level")

lvl = ds:GetAsync("Level")

local key="Player-"..plr.userId

local savedvalues=ds:GetAsync(key)

if savedvalues then

lvl.Value=savedvalues[1]

end
game.Players.PlayerRemoving:connect(function(plrr)
ds:SetAsync(key, plr.lvl.Value)
end)
end)



...but it didn't work.
Report Abuse
lululukas is not online. lululukas
Joined: 23 Aug 2010
Total Posts: 1043
17 Mar 2016 10:21 PM
you need an else as well... Okay here, ill link you a video. The audio is out of sync but you don't really need the explanations if you can read the script.

https://www.youtube(dot)com/watch?v=VXcbZ2kurvk
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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