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

Help with :WaitForDataReady()?

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?

2 comments

0

Is this in Server mode or studio mode?

0

I've tried everything, studio, server and online

1 answer

✓ Accepted answer

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

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