First:
Not sure but math.huge() might not be assignable as a number, try setting it to something like: 99999999999999
Second:
It gets updated once, try putting that in a while loop
This wont work on the client, You must place it in a Server-Sided Script
Also another issue is that you’re setting the player’s health instead of the player’s MaxHealth, Script wise you’d want to do something like this.
local player = --Get the player you want here
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
humanoid.MaxHealth = math.huge
humanoid.Health = math.huge
The reason this happens is due to the player’s MaxHealth clamping the player’s health to what its set (100 by default), you want to set the MaxHealth to the float limit aswell as the Health
Instead of giving them infinite health, a better design choice would be to simply not damage them in the first place. For example, you could make a sword not damage the player if you don’t want them to die.
this isn’t very reliable but work,
each time the player loose health, reset the health to the maximum humanoid health
if you want it very reliable you should do check, like if an player shoot another player, check if the shooted player isn’t invincible, make him take the damage
script:
local Humanoid = Character.Humanoid --replace the name
Humanoid.MaxHealth = 100000000
Humanoid.Health = Humanoid.MaxHealth
Humanoid.Health.Changed:Connect(function()
Humanoid.Health = Humanoid.MaxHealth
end)
Sorry but may I ask why we aren’t allowed to help the OP even more? What we are telling him is a way of setting the Health to its maximum when it’s damaged