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

Help with :WaitForDataReady()?

Asked by 8 years ago
savebutton.MouseButton1Down:connect(function()
    print("1")
    player:WaitForDataReady()
    print("2")
    if player.DataReady == true then
        print("3")
        saveStage(player, player.leaderstats:WaitForChild("Stage").Value)
        print("4")
        frame.Visible = false
    end 
end)

This script only prints 1, and I have tried it in a Server and a Local Script, with no difference. Why doesn't it work?

0
Is this in Server mode or studio mode? ChemicalHex 979 — 8y
0
I've tried everything, studio, server and online NinjoOnline 1146 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

I don't know why you need a button -.- This does it automatically

I didn't really understand what you we're asking for so this is my best guess

local cashkey = "cash"
game.Players.PlayerAdded:connect(function(player)
    local stats = Instance.new("IntValue", player) --Leaderboard
    stats.Name = "leaderstats"
    local cash = Instance.new("IntValue", stats) --Points/Cash
    cash.Name = "Cash"
    cash.Value = 0
player:WaitForDataReady()
cash.Value = player:LoadNumber(cashkey) --Load
end)
game.Players.PlayerRemoving:connect(function(player)
    player:SaveNumber(cashkey, player.leaderstats.Cash.Value) --Save
end)

That should work

Ad

Answer this question