Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isnt this script working?

Asked by 10 years ago
game.Players.PlayerAdded:connect(function(player)
    player:WaitForDataReady()
    if player:LoadNumber('demonlvl') and player:LoadNumber('anglelvl') == 0 or nil then
        stats = Instance.new('IntValue', player)
        stats.Name = 'leaderstat'
        demonlvl = Instance.new('IntValue', stats)
        anglelvl = Instance.new('IntValue', stats)
        demonlvl.Name = 'DemonLevel'
        anglelvl.Name = 'AngleLevel'
        demonlvl = 1
        anglelvl = 1
    end
    if player:LoadNumber('demonlvl') ~= 1 then
        demonlvl.Value = player:LoadNumber('demonlvl')
    end
    if player:LoadNumber('anglelvl') ~= 1 then
        anglelvl.Value = player:LoadNumber('anglelvl')
    end
    player:SaveNumber('demonlvl')
    player:SaveNumber('anglelvl')
end)
script.Parent.Save.MouseButton1Down:connect(function()
    player = script.Parent.Parent.Parent
    script.Parent.Save.Text = 'Saving'
    player:WaitForDataReady()
    if demonlvl ~= 0 or nil then
        player:SaveNumber('demonlvl')
    end
    if anglelvl ~= 0 or nil then
        player:SaveNumber('anglelvl')
    end
    wait(.5)
    script.Parent.Save.Text = 'Saved'
    wait(.5)
    script.Parent.Save.Text = 'Save'
end)

the parent is a screen gui and the parent of that is the starter gui... there is also another child to the screen gui and that is a save button

1 answer

Log in to vote
0
Answered by
Dominical 215 Moderation Voter
10 years ago

You're using data persistence wrong. You need a new look on that whole script. Go here: http://wiki.roblox.com/index.php?title=Data_persistence

Ad

Answer this question