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

BindToClose won't work(Different than last time)?

Ok so I fixed everything you guys told me to do last time but there are no outputs and the datastore won't work I think I did everything right but it's still not working

Money is a int value in player

also I didn't put anything for player removing because I wanted to test if game Bind To close works

I tested this in studio and in game by my self

but it still doesn't return any errors on outputs or warnings literally nothing

and it doesn't save of course

local DataS = game:GetService("DataStoreService")
local DataStore = DataS:GetDataStore('Money')


game.Players.PlayerAdded:Connect(function(plr)
	local IntValue =  Instance.new("IntValue")
	IntValue.Name = 'Money'
	IntValue.Parent = plr
	
	IntValue.Value = DataStore:GetAsync(plr.UserId,IntValue.Value) or 0
	DataStore:SetAsync(plr.UserId,IntValue.Value)
	
	
end)



game.Players.PlayerRemoving:Connect(function(plr)


	
end)



game:BindToClose(function()
	
	
for i,v in pairs(game.Players:GetPlayers()) do

	DataStore:SetAsync(v.UserId,v.Money.Value)  





	end
end)

1 answer

This is because you have no code in the player removing function. Try making it save there to... Then it may actually work.

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