|
| 22 Feb 2013 08:26 AM |
Save:
function SaveScore(plyr, score) plyr:SaveNumber("Gold", "Candy", "EXP") end
function onClicked()
player = script.Parent.Parent.Parent.Parent.Parent player:WaitForDataReady() if player.DataReady == true then SaveScore(player, player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value).Value) m = Instance.new("Message",player.PlayerGui) m.Text = script.Parent.Parent.Parent.Configuration.Type.Value.. " Saved" game:service("Debris"):AddItem(m, 3) else m = Instance.new("Message",player.PlayerGui) m.Text = "Waiting untill DataReady..." game:service("Debris"):AddItem(m, 3)
end end
script.Parent.MouseButton1Click:connect(onClicked)
Load:
function loadScore(plyr, clickCounter)
local score = plyr:LoadNumber("EXP", "Level", "Candy")
if not score == 0 then clickCounter.Value = score else print("Error, no loadvalue!") end
end
function onClicked()
player = script.Parent.Parent.Parent.Parent.Parent player:WaitForDataReady() if player.DataReady == true then loadScore(player, player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value)) player.leaderstats:findFirstChild(script.Parent.Parent.Parent.Configuration.Type.Value).Value = player:LoadNumber("Candy", "EXP", "Level") m = Instance.new("Message",player.PlayerGui) m.Text = script.Parent.Parent.Parent.Configuration.Type.Value.. " Loaded" script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 100 game:service("Debris"):AddItem(m, 3) else m = Instance.new("Message",player.PlayerGui) m.Text = "Waiting untill DataReady..." game:service("Debris"):AddItem(m, 3) end end
script.Parent.MouseButton1Click:connect(onClicked) |
|
|
| Report Abuse |
|
bibo5o
|
  |
| Joined: 17 Jan 2009 |
| Total Posts: 414 |
|
|
| 22 Feb 2013 08:44 AM |
--[[Well, one problem might be that you're loading and saving different stats...
Here's a rough outline of what you might want
these are auto's]]
function onPlayerEntered(newPlayer) newPlayer:WaitForDataReady() wait(0.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"
local Candy = Instance.new("IntValue") kills.Name = "Candy" kills.Value = 0
local Gold = Instance.new("IntValue") deaths.Name = "Gold" deaths.Value = 0
local XP = Instance.new("IntValue") points.Name = "XP" points.Value = 0
Candy.Parent = stats Gold.Parent = stats XP.Parent = stats stats.Parent = newPlayer newPlayer.leaderstats.Candy.Value = newPlayer:LoadNumber("Candy") newPlayer.leaderstats.Gold.Value = newPlayer:LoadNumber("Gold") newPlayer.leaderstats.XP.Value = newPlayer:LoadNumber("XP") end
function onPlayerLeave(oldPlayer) oldPlayer:SaveNumber("Candy", oldPlayer.leaderstats.Candy.Value) oldPlayer:SaveNumber("Gold", oldPlayer.leaderstats.Gold.Value) oldPlayer:SaveNumber("XP", oldPlayer.leaderstats.XP.Value) end
game.Players.PlayerAdded:connect(onPlayerEntered) game.Players.PlayerRemoving:connect(onPlayerLeave)
--And then there's button load and saves. This would have to go in the frame the buttons are in, and you'd also need a leaderstats script
function onPlayerEntered(newPlayer) newPlayer:WaitForDataReady() wait(0.5) local stats = Instance.new("IntValue") stats.Name = "leaderstats"
local Candy = Instance.new("IntValue") kills.Name = "Candy" kills.Value = 0
local Gold = Instance.new("IntValue") deaths.Name = "Gold" deaths.Value = 0
local XP = Instance.new("IntValue") points.Name = "XP" points.Value = 0
Candy.Parent = stats Gold.Parent = stats XP.Parent = stats stats.Parent = newPlayer newPlayer.leaderstats.Candy.Value = newPlayer:LoadNumber("Candy") newPlayer.leaderstats.Gold.Value = newPlayer:LoadNumber("Gold") newPlayer.leaderstats.XP.Value = newPlayer:LoadNumber("XP") end
function onPlayerLeave(oldPlayer) oldPlayer:SaveNumber("Candy", oldPlayer.leaderstats.Candy.Value) oldPlayer:SaveNumber("Gold", oldPlayer.leaderstats.Gold.Value) oldPlayer:SaveNumber("XP", oldPlayer.leaderstats.XP.Value) end
script.Parent.Load.MouseButton1Click:connect(onPlayerEntered) script.Parent.Save.MouseButton1Click:connect(onPlayerLeave)
--Only customizing left c: |
|
|
| Report Abuse |
|