heres the script
if game.Players.LocalPlayer.Character.Humanoid.MaxHealth = math.huge then game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 0 else game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 100 end if game.Players.LocalPlayer.Character.Humanoid.Health = math.huge then game.Players.LocalPlayer.Character.Humanoid.Health = 0 else game.Players.LocalPlayer.Character.Humanoid.Health = 100
You seem to be missing an end at the end. Also, you might want to do a check every few seconds like this:
while true do wait (1) if game.Players.LocalPlayer.Character.Humanoid.MaxHealth = math.huge then game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 0 else game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 100 end if game.Players.LocalPlayer.Character.Humanoid.Health = math.huge then game.Players.LocalPlayer.Character.Humanoid.Health = 0 else game.Players.LocalPlayer.Character.Humanoid.Health = 100 end end
I used variables to shorten it also, I would recommend using WaitForChild
to get Humanoid and CharacterAdded:wait()
to get character.
EDIT: Added a loop
plr = game.Players.LocalPlayer char = plr.CharacterAdded:wait() human = char:WaitForChild('Humanoid') -- Waits for Humanoid so it's detected while wait(5) do -- every 5 seconds, it checks for the health. if human.MaxHealth == math.huge then -- It's best to use MaxHealth since the health can't be more than MaxHealth. human.MaxHealth = 0 -- sets max health to zero if maxhealth = math.huge human.Health = 0 -- sets health to zero if health = math.huge else human.MaxHealth = 100 human.Health = 100 end