Please help me out guys how do you change the amount of health your character has in a game.Does an infinite value even exist? Changing it such that it is saved everytime the character respawns.
✓ ANSWER ACCEPTED
Health change or INFINITE HEALTH of the character in ROBLOX?
2 answers
✓ Accepted answer
To do this, simply use math.huge!
Example in a server script:
wait(1)
local plrs = game.Players:GetPlayers() --Replace with target player/character
local chr = plrs[1].Character --Get player character
--Set both maxhealth and health to an infinite value
chr.Humanoid.MaxHealth = math.huge
chr.Humanoid.Health = math.huge
--Test the infinite values by repeatedly trying to damage the player.
while true do
chr.Humanoid:TakeDamage(100)
print("DAMAGE TAKEN")
wait(1)
end
Don't use while loops, bad practice.
In a server script
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
local ChangeHealth
Player.CharacterAdded:Connect(function(Character)
if ChangeHealth ~= nil then
ChangeHealth:Disconnect()
end
local Humanoid = Character:WaitForChild("Humanoid")
local MaxHealth = 2147483647
Humanoid.MaxHealth = MaxHealth
ChangeHealth = Humanoid.HealthChanged:Connect(function()
Humanoid.Health = MaxHealth
end)
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
If you want a gear to stop killing players, remove the scripts but leave the handle.