|
| 09 Jun 2015 10:15 PM |
My leaderstats only save for me and no one else?
I've tried many different leaderstat save scripts that i made, all them did the same
Then I tried fms thinking 'It's probably me messing up, lets check other scripts'
tried over 50 FMs and over 10 of my own rewrites
Nothing works?
Anyone know why?
It's only 1 leaderstat, so it isn't overflowing either |
|
|
| Report Abuse |
|
|
| |
|
hyyt8
|
  |
| Joined: 02 May 2007 |
| Total Posts: 1760 |
|
|
| 09 Jun 2015 10:26 PM |
--Put this in the workspace
while wait(.1) do for i,p in pairs(game.Players:GetChildren()) do if p.PlayerGui:findFirstChild("leaderstats") then p:WaitForDataReady() p:SaveInstance("Stats", p.leaderstats) end end end
--Put this in the StarterGui
p = script.Parent.Parent p:WaitForDataReady() local stats = p:LoadInstance("Stats") if stats then stats.Parent = p else leaderstat = Instance.new("IntValue") leaderstat.Name = "leaderstats" leaderstat.Parent = p stat1 = Instance.new("IntValue") stat1.Name = "Name of Stat" stat1.Value = "Value of Stat" stat1.Parent = leaderstat end wait() script:Destroy() end) |
|
|
| Report Abuse |
|
|
| |
|
Traide
|
  |
| Joined: 13 Apr 2012 |
| Total Posts: 105 |
|
|
| 09 Jun 2015 10:39 PM |
Is the value in the player or in the leaderstat in the player? Because if the stat is just in the player, I have a script for that
Traide || Quarad CEO |
|
|
| Report Abuse |
|
|
hyyt8
|
  |
| Joined: 02 May 2007 |
| Total Posts: 1760 |
|
|
| 09 Jun 2015 10:41 PM |
Had a typo. Just check the output please.
p = script.Parent.Parent p:WaitForDataReady() local stats = p:LoadInstance("Stats") if stats then stats.Parent = p else leaderstat = Instance.new("IntValue") leaderstat.Name = "leaderstats" leaderstat.Parent = p stat1 = Instance.new("IntValue") stat1.Name = "Name of Stat" stat1.Value = "Value of Stat" stat1.Parent = leaderstat end wait() script:Destroy() |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 09 Jun 2015 10:50 PM |
| http://www.roblox.com/Forum/ShowPost.aspx?PostID=162506822 |
|
|
| Report Abuse |
|
|
Traide
|
  |
| Joined: 13 Apr 2012 |
| Total Posts: 105 |
|
|
| 09 Jun 2015 10:54 PM |
Here's a fully function script (I tested) *regular script in workspace*
function PlayerJoined(Player) if Player:FindFirstChild("leaderstats") == nil then local Val = Instance.new("IntValue", Player) Val.Name = "leaderstats" end if Player.leaderstats:FindFirstChild("Money") == nil then local Val = Instance.new("IntValue", Player.leaderstats) Val.Name = "Money" Val.Value = 0 Player:WaitForDataReady() local Loaded = Player:LoadNumber("MoneyNum") if Loaded ~= 0 and Loaded ~= nil then Val.Value = Loaded
end end end
game.Players.PlayerAdded:connect(PlayerJoined)
function playerRemoving(player) if player.leaderstats:FindFirstChild("Money") ~= nil then print("startedfunctionm8") local Val = player.leaderstats:FindFirstChild("Money") player:SaveNumber("MoneyNum", Val.Value) print("completedfunctionm8") end end
game.Players.PlayerRemoving:connect(playerRemoving)
Traide || Quarad CEO |
|
|
| Report Abuse |
|
|
Traide
|
  |
| Joined: 13 Apr 2012 |
| Total Posts: 105 |
|
|
| 09 Jun 2015 10:54 PM |
Thats a script that loads it, and saves it.
Traide || Quarad CEO |
|
|
| Report Abuse |
|
|
vacha
|
  |
| Joined: 06 Jan 2011 |
| Total Posts: 1993 |
|
|
| 09 Jun 2015 10:56 PM |
OMI use datastore
while true do the do |
|
|
| Report Abuse |
|
|
Traide
|
  |
| Joined: 13 Apr 2012 |
| Total Posts: 105 |
|
| |
|
hyyt8
|
  |
| Joined: 02 May 2007 |
| Total Posts: 1760 |
|
|
| 09 Jun 2015 11:01 PM |
| PlayerRemoved doesn't always trigger before data is ready, so mine was an autosave |
|
|
| Report Abuse |
|
|
Traide
|
  |
| Joined: 13 Apr 2012 |
| Total Posts: 105 |
|
|
| 09 Jun 2015 11:04 PM |
Well I don't think your value would go up when 1 second into the game, k. Case closed :3
Traide || Quarad CEO |
|
|
| Report Abuse |
|
|
hyyt8
|
  |
| Joined: 02 May 2007 |
| Total Posts: 1760 |
|
|
| 09 Jun 2015 11:09 PM |
| It saves ten times a second. Plenty of time to save before your game crashes or you hit exit |
|
|
| Report Abuse |
|
|
Traide
|
  |
| Joined: 13 Apr 2012 |
| Total Posts: 105 |
|
|
| 09 Jun 2015 11:10 PM |
"It saves ten times a second" --Dat Lag :> ---#MineReducesLag, k
Traide || Quarad CEO |
|
|
| Report Abuse |
|
|
hyyt8
|
  |
| Joined: 02 May 2007 |
| Total Posts: 1760 |
|
|
| 09 Jun 2015 11:13 PM |
| Mine saves stats when the game crashes, yours doesn't. Besides it's being overwritten not added, so it doesn't cause lag. |
|
|
| Report Abuse |
|
|
Traide
|
  |
| Joined: 13 Apr 2012 |
| Total Posts: 105 |
|
|
| 09 Jun 2015 11:17 PM |
PlayerRemoving is triggered also when a game is crashed ya know. ;)
Traide || Quarad CEO |
|
|
| Report Abuse |
|
|