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: Saving (Data Persistence)

Previous Thread :: Next Thread 
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
26 Mar 2014 12:41 AM
I have tried a million different ways, but I can not figure out a way to make these stats save... Can someone please help me with a save script for this leaderboard?


function onXPChanged(player, XP, level)
if XP.Value>=level.Value * 10 then
XP.Value = XP.Value - level.Value * 10
level.Value = level.Value + 1
end
end

function onLevelUp(player, XP, level)
if player.Character~=nil then
for i = 1,5 do
local fireworks = Instance.new("Part")
fireworks.Shape = 0
fireworks.formFactor = "Symmetric"
fireworks.Size = Vector3.new(1,1,1)
fireworks.BrickColor = BrickColor.Random()
fireworks.CFrame = player.Character.Head.CFrame + Vector3.new(0,2,0)
fireworks.Parent = game.Workspace
game:GetService("Debris"):AddItem(fireworks, 2)
fireworks.Velocity = Vector3.new(math.random(-30,30),math.random(-30,30),math.random(-30,30))
end
end
end

function onPlayerRespawned(player)
wait(5)
player.Character.Humanoid.Health = player.leaderstats.Level * 999
player.Character.Humanoid.MaxHealth = player.leaderstats.Level * 1000

end

function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue")
stats.Name = "stats"

local xp = Instance.new("IntValue")
xp.Name = "XP"
xp.Value = 0

local level = Instance.new("IntValue")
level.Name = "Level"
level.Value = 5

local c = Instance.new("IntValue")
c.Name = "Cash"
c.Value = 15

local t = Instance.new("IntValue")
t.Name = "Type"
t.Value = 0

local t2 = Instance.new("IntValue")
t2.Name = "Type2"
t2.Value = 0

local p = Instance.new("IntValue")
p.Name = "Potion"
p.Value = 3

local ts = Instance.new("IntValue")
ts.Name = "ThunderStone"
ts.Value = 0

local w = Instance.new("IntValue")
w.Name = "WaterStone"
w.Value = 0

local f = Instance.new("IntValue")
f.Name = "FireStone"
f.Value = 0

local r = Instance.new("IntValue")
r.Name = "Friendship"
r.Value = 10

xp.Parent = stats
level.Parent = stats
c.Parent = stats
t.Parent = stats
t2.Parent = stats
p.Parent = stats
ts.Parent = stats
w.Parent = stats
f.Parent = stats
r.Parent = stats

stats.Parent = newPlayer

xp.Changed:connect(function() onXPChanged(newPlayer, xp, level) end)
level.Changed:connect(function() onLevelUp(newPlayer, xp, level) end)

newPlayer.Changed:connect(function (property)
if (property == "Character") then
onPlayerRespawned(newPlayer)
end
end)
end

game.Players.ChildAdded:connect(onPlayerEntered)
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
26 Mar 2014 08:37 PM
Bump
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
26 Mar 2014 08:46 PM
free model
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
26 Mar 2014 08:53 PM
? :/ that's not help.
Report Abuse
A8U is not online. A8U
Joined: 25 Mar 2014
Total Posts: 63
26 Mar 2014 08:53 PM
Just use DataStoreService...
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
26 Mar 2014 08:57 PM
DataStore? Is that like data persistence?
Report Abuse
A8U is not online. A8U
Joined: 25 Mar 2014
Total Posts: 63
26 Mar 2014 08:58 PM
Yes, but the players stats can be accessed without the player being in game!
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
26 Mar 2014 09:04 PM
Oh, very cool! Unfortunately I don't know anything about data store. Do you think you could post a script I would use to save the stats for this leaderboard? Or possibly direct me to a wiki? Or maybe even both? :P
Report Abuse
A8U is not online. A8U
Joined: 25 Mar 2014
Total Posts: 63
26 Mar 2014 09:06 PM
http://wiki.roblox.com/index.php/DataStoreService
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
26 Mar 2014 09:15 PM
Does this script look right if I want the player's cash stat to be the same when they come back to the game after leaving.



local DataStore = game:GetService("DataStoreService"):GetDataStore("Cash")

game.Players.PlayerAdded:connect(function(player)
local key = "user_" .. player.userId
DataStore:UpdateAsync(key, function(oldValue)
local newValue = oldValue or 0
newValue = newValue
return newValue
end)
end)
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
26 Mar 2014 09:25 PM
k
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
26 Mar 2014 09:25 PM
???? Can someone please help me make it so these stats save and load?
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
26 Mar 2014 09:31 PM
yes we can
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
26 Mar 2014 09:35 PM
What would it take for your help Robot? I could really use it? Please.
Report Abuse
TaylorBruska is not online. TaylorBruska
Joined: 25 Mar 2014
Total Posts: 115
26 Mar 2014 09:36 PM
This helpt me a lot! not
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
26 Mar 2014 09:51 PM
Bump. Can someone please help?
Report Abuse
drco12 is not online. drco12
Joined: 26 Sep 2009
Total Posts: 234
27 Mar 2014 12:07 AM
Bump.
Report Abuse
maxomega3 is not online. maxomega3
Joined: 11 Jun 2010
Total Posts: 10668
27 Mar 2014 12:11 AM
Sorry man. Data Store is tough, and fairly new, so there isn't much to look at. I'm in this with you. Here's a bump.
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