local datastore = game:GetService("DataStoreService")
local ds2 = datastore:GetDataStore("savecolor1111")
local SaveEvent = game.ReplicatedStorage.ColorEvent1

game.Players.PlayerAdded:connect(function(plr)
local Water = plr:WaitForChild("SaveColor1"):WaitForChild("Value")


 
 Water.Value = ds2:GetAsync(plr.UserId) or 0
 ds2:SetAsync(plr.UserId, Water.Value)
 


end)

SaveEvent.OnServerEvent:Connect(function(oldplr)
local Water = oldplr:WaitForChild("SaveColor1"):WaitForChild("Value")
	ds2:SetAsync(oldplr.UserId, Water.Value)
	print("saved")
	end)
game.Players.PlayerRemoving:Connect(function(plr)
	local Water = plr:WaitForChild("SaveColor1"):WaitForChild("Value")
	ds2:SetAsync(plr.UserId, Water.Value)
	print("saved")

end)

what im doing wrong?

1 comment

0

Never save data based on when the client wants to save. That'll lead to terrible issues down the road.