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
|
  |
| Joined: 26 Sep 2009 |
| Total Posts: 234 |
|
| |
|
| |
|
drco12
|
  |
| Joined: 26 Sep 2009 |
| Total Posts: 234 |
|
| |
|
A8U
|
  |
| Joined: 25 Mar 2014 |
| Total Posts: 63 |
|
|
| 26 Mar 2014 08:53 PM |
| Just use DataStoreService... |
|
|
| Report Abuse |
|
|
drco12
|
  |
| Joined: 26 Sep 2009 |
| Total Posts: 234 |
|
|
| 26 Mar 2014 08:57 PM |
| DataStore? Is that like data persistence? |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| Joined: 25 Mar 2014 |
| Total Posts: 63 |
|
|
| 26 Mar 2014 09:06 PM |
| http://wiki.roblox.com/index.php/DataStoreService |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
| |
|
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
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
| |
|
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 |
|
|
| |
|
drco12
|
  |
| Joined: 26 Sep 2009 |
| Total Posts: 234 |
|
|
| 26 Mar 2014 09:51 PM |
| Bump. Can someone please help? |
|
|
| Report Abuse |
|
|
drco12
|
  |
| Joined: 26 Sep 2009 |
| Total Posts: 234 |
|
| |
|
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 |
|
|