I have been trying to save a number with data stores but it doesn't save ;L

It also interferes with another save system and it doesn't save the other value

local DataStore = game:GetService("DataStoreService")
local ds3 = DataStore:GetDataStore("MaxHealthSaveSystem")

game.Players.PlayerAdded:connect(function(player)
	local maxhealth = workspace:WaitForChild(player).Humanoid.MaxHealth
	ds3:SetAsync(player.UserId, maxhealth.Value)
	maxhealth.Changed:connect(function()
		ds3:SetAsync(player.UserId, maxhealth)
	end)
end)

game.Players.PlayerRemoving:connect(function(player)
	local maxhealth = workspace:WaitForChild(player).Humanoid.MaxHealth
	ds3:SetAsync(player.UserId, maxhealth)
end)

3 comments

0

Idk if it matters, but I don't use numbers in my variables.

0

It matters crazy cat

0

That would error on the fifth line, since you're passing a Player instance to WaitForChild instead of a string.