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: how can I make this script save

Previous Thread :: Next Thread 
JoeyOrTiger is not online. JoeyOrTiger
Joined: 29 Jun 2009
Total Posts: 641
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
JoeyOrTiger is not online. JoeyOrTiger
Joined: 29 Jun 2009
Total Posts: 641
06 Dec 2015 01:22 AM
plz help me or i will kick a cat
Report Abuse
Casualist is not online. 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
JoeyOrTiger is not online. JoeyOrTiger
Joined: 29 Jun 2009
Total Posts: 641
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 is not online. 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
JoeyOrTiger is not online. JoeyOrTiger
Joined: 29 Jun 2009
Total Posts: 641
06 Dec 2015 02:51 AM
I'm too stupid to understand what you just said :l
thanks anyway tho
Report Abuse
RobuxLife is not online. RobuxLife
Joined: 19 Sep 2012
Total Posts: 13336
06 Dec 2015 06:42 AM
For short:

use data store
Report Abuse
JoeyOrTiger is not online. JoeyOrTiger
Joined: 29 Jun 2009
Total Posts: 641
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
JoeyOrTiger is not online. JoeyOrTiger
Joined: 29 Jun 2009
Total Posts: 641
06 Dec 2015 08:47 PM
PLZZZZ HELP ME BEFORE I SUICIDE I BEG U PLZ
Report Abuse
JoeyOrTiger is not online. JoeyOrTiger
Joined: 29 Jun 2009
Total Posts: 641
06 Dec 2015 09:09 PM
HELLLLLLPPPP PLZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
Report Abuse
JoeyOrTiger is not online. JoeyOrTiger
Joined: 29 Jun 2009
Total Posts: 641
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
JoeyOrTiger is not online. JoeyOrTiger
Joined: 29 Jun 2009
Total Posts: 641
06 Dec 2015 09:25 PM
plllllllzzzzzzzzz
Report Abuse
Metology is not online. 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
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