Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont this save script work? [Still need help]

function enter(plr)
	repeat wait() until plr.Character.Head~= nil
wait(0)
	local stats = plr
	local w = Instance.new("IntValue")
	w.Name = "Fly"
	w.Value = 2
	w.Parent = stats
	local w = Instance.new("IntValue")
	w.Name = "Damage"
	w.Value = 4.6
	w.Parent = stats
	local w = Instance.new("IntValue")
	w.Name = "Music"
	w.Value = 138103237
	w.Parent = stats
	wait(0)
	plr.Fly.Value = plr:LoadNumber("Fly")
	wait(0)
	plr.Fly.Value = plr:LoadNumber("Damage")
	wait(0)
	plr.Fly.Value = plr:LoadNumber("Music")

end
function leave(plr)
	plr:SaveNumber("Fly", plr.leaderstats.Gold.Value)
	plr:SaveNumber("Damage", plr.leaderstats.Gold.Value)
	plr:SaveNumber("Music", plr.leaderstats.Gold.Value)
end
game.Players.PlayerAdded:connect(enter)
game.Players.PlayerRemoving:connect(leave)

2 comments

0

Have you considered using DataStores? I would also make a .CharacterAdded function for the player instead of the repeat wait() until player.Character.Head~=nil.

0

..? what does this mean

1 answer

I'm 100% not sure about this First: Are you kidding me? or that was just a test?

plr:SaveNumber("Fly", plr.leaderstats.Gold.Value)
plr:SaveNumber("Damage", plr.leaderstats.Gold.Value)
plr:SaveNumber("Music", plr.leaderstats.Gold.Value)

^I don't think plr.leaderstats.Gold.Value exists...

Try this: (onAdded)

    local stats = plr
    local w1 = Instance.new("IntValue")
    w1.Name = "Fly"
    w1.Value = 2
    w1.Parent = stats
    local w2 = Instance.new("IntValue")
    w2.Name = "Damage"
    w2.Value = 4.6
    w2.Parent = stats
    local w3 = Instance.new("IntValue")
    w3.Name = "Music"
    w3.Value = 138103237
    w3.Parent = stats
    wait(0)
    w1.Value = plr:LoadNumber("Fly")
    wait(0)
    w2.Value = plr:LoadNumber("Damage")
    wait(0)
    w3.Fly.Value = plr:LoadNumber("Music")

Please don't tell me you coded it while sleeping. You have made so many mistakes, xD I thought i kinda remade the code, Enjoy!

This discussion is preserved as it was. New answers, comments, and votes are closed.