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: Data Perstistance Saving

Previous Thread :: Next Thread 
jhend27513 is not online. jhend27513
Joined: 17 Sep 2011
Total Posts: 3369
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
jhend27513 is not online. jhend27513
Joined: 17 Sep 2011
Total Posts: 3369
01 Jun 2013 04:25 PM
Nobody can help?
Report Abuse
robloxboy54 is not online. robloxboy54
Joined: 20 Nov 2010
Total Posts: 286
01 Jun 2013 04:27 PM
(:
Report Abuse
jhend27513 is not online. jhend27513
Joined: 17 Sep 2011
Total Posts: 3369
01 Jun 2013 04:35 PM
Get out. Right now. Get OUT.
Report Abuse
robloxboy54 is not online. robloxboy54
Joined: 20 Nov 2010
Total Posts: 286
02 Jun 2013 08:40 AM
-_- (:
Report Abuse
VirtualUser is not online. VirtualUser
Joined: 16 Aug 2010
Total Posts: 533
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 is not online. 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
jhend27513 is not online. jhend27513
Joined: 17 Sep 2011
Total Posts: 3369
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
jhend27513 is not online. jhend27513
Joined: 17 Sep 2011
Total Posts: 3369
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 is not online. 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
jhend27513 is not online. jhend27513
Joined: 17 Sep 2011
Total Posts: 3369
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 is not online. spearman2
Joined: 28 May 2010
Total Posts: 2938
02 Jun 2013 07:20 PM
Yes! Milked it!
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