Hello, developers!
I’m trying to set the player’s Health to their MaxHealth upon respawn. For some reason, it prints that the value of Health is 200 (the desired value) but it is still set to 100 on the client and the server.
My Code:
game:GetService("Players").PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
wait(5)
character.Humanoid.Health = character.Humanoid.MaxHealth
print(character.Humanoid.Health)
print(character.Humanoid.MaxHealth)
-- THE FOLLOWING PART HAS TO DO WITH OTHER SYSTEMS AND IS UNRELATED TO THIS
if player.Team == game.Teams.Runners and player:WaitForChild("Lives").Value ~= 4 then
player:WaitForChild("Lives").Value -= 1
if player.Lives.Value == 0 then
wait(1)
player.PlayerGui.RunnerGui.Died.Visible = true
player.Character.HumanoidRootPart.CFrame = game.Workspace.SpawnLocation1.CFrame + Vector3.new(0, 10, 0)
task.wait(16)
if player.Lives.Value == 0 then
player.PlayerGui.RunnerGui.Died.Visible = false
player.TeamColor = game.Teams:FindFirstChild("Lobby").TeamColor
game.Players[game.ReplicatedStorage.Values.Tagger.Value]:WaitForChild("leaderstats").Coins.Value += 25
end
end
end
end)
end)
end)