|
| 06 Dec 2015 01:18 AM |
please help me this script works but doesnt save, it erases everything when you leave
local sp = script.Parent local folder = sp.Frame -- local adminColor = BrickColor.new("Bright yellow") --The textcolor of admins local defaultColor = BrickColor.new("Really black") --Normal player color -- local admins = {kryptonikofficial=1,player1=1} --lowercase --
function refresh() folder:ClearAllChildren() -- local stats = {} -- for _,plr in pairs(game.Players:GetPlayers()) do if plr:findFirstChild("leaderstats") then local label = Instance.new("TextLabel", folder) label.Font = "Legacy" label.FontSize = "Size18" label.Size = UDim2.new(1,0,0,30) label.BackgroundColor = BrickColor.new("Dark stone grey") label.Text = "["..plr.Name.."]" if admins[plr.Name:lower()] then label.TextColor = adminColor else label.TextColor = defaultColor end for _,ls in pairs(plr.leaderstats:GetChildren()) do table.insert(stats, ls.Name) end for i = 1, #stats do local statName = stats[i] local statValue = plr.leaderstats[stats[i]].Value label.Text = label.Text.. " "..statName..": "..statValue end stats = {} for i,c in pairs(folder:GetChildren()) do c.Position = c.Position + UDim2.new(0,0,0,33) end end end end
game.Players.PlayerAdded:connect(function(p) p:WaitForChild("leaderstats") refresh() end)
game.Players.PlayerRemoving:connect(function() refresh() end)
script.refresh.Event:connect(refresh)
|
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 01:22 AM |
| plz help me or i will kick a cat |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 06 Dec 2015 01:26 AM |
| Elaborate. This doesn't seem to overwrite any data. |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 02:00 AM |
when i join the game it will show all my leaderstats perfectly but when I leave the game it erases the leaderboard D: please help me i beg you |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 06 Dec 2015 02:08 AM |
If this is for a PersonalServer you might want to lead with that.
The issue is that A) You delete everything in the folder and only create labels for people who are in servers, so this would delete old data generated by other users. B) Since you are only updating values for people who are still in the server, PlayerData will not be saved for people leaving the server. |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 02:51 AM |
I'm too stupid to understand what you just said :l thanks anyway tho |
|
|
| Report Abuse |
|
|
RobuxLife
|
  |
| Joined: 19 Sep 2012 |
| Total Posts: 13336 |
|
| |
|
|
| 06 Dec 2015 08:27 PM |
i try this but still doesnt work please help
local sp = script.Parent local folder = sp.Frame
function refresh() folder:ClearAllChildren()
local stats = {}
for _,plr in pairs(game.Players:GetPlayers()) do if plr:findFirstChild("leaderstats") then local label = Instance.new("TextLabel", folder) label.Font = "Legacy" label.FontSize = "Size18" label.Size = UDim2.new(1,0,0,30) label.BackgroundColor = BrickColor.new("Dark stone grey") label.Text = "["..plr.Name.."]" for _,ls in pairs(plr.leaderstats:GetChildren()) do table.insert(stats, ls.Name) end for i = 1, #stats do local statName = stats[i] local statValue = plr.leaderstats[stats[i]].Value label.Text = label.Text.. " "..statName..": "..statValue end
stats = {} for i,c in pairs(folder:GetChildren()) do c.Position = c.Position + UDim2.new(0,0,0,33) end end end end game.Players.PlayerAdded:connect(function(p) p:WaitForChild("leaderstats") if workspace:FindFirstChild("leaderstats") then game:LoadInstance("leaderstats").Parent = workspace end refresh() end) game.Players.PlayerRemoving:connect(function(plr) refresh() game:SaveInstance("leaderstats", workspace.leaderstats) end)
script.refresh.Event:connect(refresh)
|
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 08:47 PM |
| PLZZZZ HELP ME BEFORE I SUICIDE I BEG U PLZ |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 09:09 PM |
| HELLLLLLPPPP PLZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
|
|
| Report Abuse |
|
|
|
| 06 Dec 2015 09:13 PM |
HELP PLEASE ساعدني Βοήθησέ με Hilf mir 幫我 Помоги мне Aidez moi auta minua pomozi mi Cabhraigh liom (wtf ireland has its own language?) 도와주세요 bana yardım et hjälp mig дапамагчы мне
|
|
|
| Report Abuse |
|
|
| |
|
Metology
|
  |
| Joined: 06 Oct 2014 |
| Total Posts: 3255 |
|
|
| 06 Dec 2015 09:28 PM |
Data Persistence function onPlayerEntered(newPlayer)
newPlayer:WaitForDataReady() newPlayer.leaderstats.Points.Value = newPlayer:LoadNumber("Points") end
function onPlayerLeave(oldPlayer)
oldPlayer:SaveNumber("Points", oldPlayer.leaderstats.Points.Value) end
game.Players.PlayerAdded:connect(onPlayerEntered) game.Players.PlayerRemoving:connect(onPlayerLeave)
|
|
|
| Report Abuse |
|
|