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 » Scripters
Home Search
 

Re: leaderstats saving issue

Previous Thread :: Next Thread 
CrixusOdalisManiatus is not online. CrixusOdalisManiatus
Joined: 16 Jun 2011
Total Posts: 5987
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
CrixusOdalisManiatus is not online. CrixusOdalisManiatus
Joined: 16 Jun 2011
Total Posts: 5987
09 Jun 2015 10:15 PM
wow 1 view
Report Abuse
hyyt8 is not online. 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
CrixusOdalisManiatus is not online. CrixusOdalisManiatus
Joined: 16 Jun 2011
Total Posts: 5987
09 Jun 2015 10:32 PM
doesnt work
Report Abuse
Traide is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Traide
Joined: 13 Apr 2012
Total Posts: 105
09 Jun 2015 10:59 PM
eh ;p



Traide || Quarad CEO
Report Abuse
hyyt8 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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