|
| 01 Jun 2013 04:14 PM |
function newPlayer(player) player:WaitForDataReady() local stats = Instance.new("IntValue") stats.Name = "leaderstats"
local points = Instance.new("IntValue") points.Name = "Points" points.Value = 0
local survivals = Instance.new("IntValue") survivals.Name = "Survivals" survivals.Value = 0
points.Parent = stats survivals.Parent = stats stats.Parent = player local ok, ret = pcall(function() return player:LoadNumber(scoreKey) end) if ok then if ret ~= 0 then player.leaderstats.Points.Value = ret else print("Nothing to load/score was 0") end else print("Error:", ret) end end
game.Players.PlayerRemoving:connect(function(player) --if a player leaves before the leaderstats have been created it won't crash the script, as it's in a pcall local succ, ret = pcall(function() player:SaveNumber(scoreKey,player.leaderstats.Points.Value) end) if succ then print("Successfully saved") else print("Saving error:", ret) end end)
It is supposed to save your Points. Why isn't it working? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 01 Jun 2013 04:35 PM |
| Get out. Right now. Get OUT. |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Jun 2013 09:04 AM |
The first argument for both LoadNumber and SaveNumber, as well as all the other "load"s and "save"s, is a string. You are not setting it as a string.
What you are doing: player:LoadNumber(scoreKey)
What you should be doing player:LoadNumber("scoreKey")
|
|
|
| Report Abuse |
|
|
spearman2
|
  |
| Joined: 28 May 2010 |
| Total Posts: 2938 |
|
|
| 02 Jun 2013 09:55 AM |
pts = "Points" die = "Survivals"
function newPlayer(player) player:WaitForDataReady() local stats = Instance.new("IntValue") stats.Name = "leaderstats"
local points = Instance.new("IntValue") points.Name = "Points" points.Value = player:LoadNumber(pts, points.Value)
local survivals = Instance.new("IntValue") survivals.Name = "Survivals" survivals.Value = player:LoadNumber(die, survivals.Value)
points.Parent = stats survivals.Parent = stats stats.Parent = player end end
game.Players.PlayerRemoving:connect(function(player) if player.DataReady then ld = player.leaderstats local succ, ret = pcall(function() player:SaveNumber(pts, ld.Points.Value) player:SaveNumber(die, ld.Survivals.Value) end) end end)
there that should work, I hope |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2013 10:05 AM |
Would this work Virtual User? function newPlayer(player) player:WaitForDataReady() local stats = Instance.new("IntValue") stats.Name = "leaderstats"
local points = Instance.new("IntValue") points.Name = "Points" points.Value = 0
local survivals = Instance.new("IntValue") survivals.Name = "Survivals" survivals.Value = 0
points.Parent = stats survivals.Parent = stats stats.Parent = player local ok, ret = pcall(function() return player:LoadNumber("scoreKey") end) if ok then if ret ~= 0 then player.leaderstats.Points.Value = ret else print("Nothing to load/score was 0") end else print("Error:", ret) end end
game.Players.PlayerRemoving:connect(function(player) --if a player leaves before the leaderstats have been created it won't crash the script, as it's in a pcall local succ, ret = pcall(function() player:SaveNumber("scoreKey",player.leaderstats.Points.Value) end) if succ then print("Successfully saved") else print("Saving error:", ret) end end)
~Hey I just posted, and this is crazy, but this is a siggy, http://www.roblox.com/Water-Flood-Updates-V-1-1-4-place?id=111589417 play my game maybe? ~ |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2013 10:06 AM |
I mean't to paste this ::
function newPlayer(player) player:WaitForDataReady() local stats = Instance.new("IntValue") stats.Name = "leaderstats"
local points = Instance.new("IntValue") points.Name = "Points" points.Value = 0
local survivals = Instance.new("IntValue") survivals.Name = "Survivals" survivals.Value = 0
points.Parent = stats survivals.Parent = stats stats.Parent = player local ok, ret = pcall(function() return player:LoadNumber("scoreKey") end) if ok then if ret ~= 0 then player.leaderstats.Points.Value = ret else print("Nothing to load/score was 0") end else print("Error:", ret) end end
game.Players.PlayerRemoving:connect(function(player) --if a player leaves before the leaderstats have been created it won't crash the script, as it's in a pcall local succ, ret = pcall(function() player:SaveNumber("scoreKey",player.leaderstats.Points.Value) end) if succ then print("Successfully saved") else print("Saving error:", ret) end end)
~Hey I just posted, and this is crazy, but this is a siggy, http://www.roblox.com/Water-Flood-Updates-V-1-1-4-place?id=111589417 play my game maybe? ~
~Hey I just posted, and this is crazy, but this is a siggy, http://www.roblox.com/Water-Flood-Updates-V-1-1-4-place?id=111589417 play my game maybe? ~ |
|
|
| Report Abuse |
|
|
spearman2
|
  |
| Joined: 28 May 2010 |
| Total Posts: 2938 |
|
|
| 02 Jun 2013 10:49 AM |
pts = "Points" die = "Survivals"
game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() local stats = Instance.new("IntValue") stats.Name = "leaderstats"
local points = Instance.new("IntValue") points.Name = "Points" points.Value = player:LoadNumber(pts, points.Value)
local survivals = Instance.new("IntValue") survivals.Name = "Survivals" survivals.Value = player:LoadNumber(die, survivals.Value)
points.Parent = stats survivals.Parent = stats stats.Parent = player end end
game.Players.PlayerRemoving:connect(function(player) if player.DataReady then ld = player.leaderstats local succ, ret = pcall(function() player:SaveNumber(pts, ld.Points.Value) player:SaveNumber(die, ld.Survivals.Value) end) end end) |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2013 11:29 AM |
Works great! Thanks!
~Hey I just posted, and this is crazy, but this is a siggy, http://www.roblox.com/Water-Flood-Updates-V-1-1-4-place?id=111589417 play my game maybe? ~ |
|
|
| Report Abuse |
|
|
spearman2
|
  |
| Joined: 28 May 2010 |
| Total Posts: 2938 |
|
| |
|