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
 

Help please.

Previous Thread :: Next Thread 
ScriptMasterMatt is not online. ScriptMasterMatt
Joined: 01 Sep 2009
Total Posts: 1164
28 Jun 2014 12:14 AM
Ok, so everything works except the player removing event. The event works I'm pretty sure, but it's not changing the value. It's supposed to set my value to 1337 and then when I rejoin my value will be 1337 but instead when it loads it's 0. Why is this?

--[[Basically skip down until the player removing event, I just figured I should post the whole script.--]]





local statsDataStore = game:service("DataStoreService"):GetDataStore("StatsData")

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(character)
p:WaitForChild("PlayerGui")
p.PlayerGui:WaitForChild("stats")
if statsDataStore ~= nil then
local stats = statsDataStore:GetAsync(p.userId)
p.PlayerGui.stats.Value.Value = stats
end
end)
end)

game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(character)
character.Humanoid.Died:connect(function(saver)
p:WaitForChild("PlayerGui")
p.PlayerGui:WaitForChild("stats")
if statsDataStore ~= nil then
statsDataStore:SetAsync(p.userId, p.PlayerGui.stats.Value.Value)
end
end)
end)
end)




game.Players.PlayerRemoving:connect(function(byeP)
p:WaitForChild("PlayerGui")
p.PlayerGui:WaitForChild("stats")
p.PlayerGui.stats.Value.Value = 1337
if statsDataStore ~= nil then

statsDataStore:SetAsync(byeP.userId, byeP.PlayerGui.stats.Value.Value)
end
end)
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
28 Jun 2014 12:25 AM
in the function you have (byeP) but in the code you try to access 'p' instead
Report Abuse
ScriptMasterMatt is not online. ScriptMasterMatt
Joined: 01 Sep 2009
Total Posts: 1164
28 Jun 2014 12:33 AM
oh crap, thanks man.
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