Ive been trying to save each seperate players "MaxHealth" So they can rejoin the server/die and get back their max health I've tried multiple scripts so I was wondering how I would fix it I would expect this script to work but sadly it does not D:
local DataStore = game:GetService("DataStoreService")
local ds3 = DataStore:GetDataStore("MaxHealthSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local maxhealth = Instance.new("IntValue",player)
maxhealth.Name = "MaxHealth"
local forever = 2
repeat
local botty = workspace:WaitForChild(player.Name).Humanoid.MaxHealth
maxhealth.Value = botty
until forever == 2
maxhealth.Value = ds3:GetAsync(player.UserId) or 0
ds3:SetAsync(player.UserId, maxhealth.Value)
maxhealth.Changed:connect(function()
ds3:SetAsync(player.UserId, maxhealth.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds3:SetAsync(player.UserId, player.leaderstats.MaxHealth.Value)
end)
