How do i set values back to what they were before

So all i want to do is set the humanoid’s Health and MaxHealth to math.huge then return them back to their old values after a few seconds.

variables

local function Invincible(Humanoid, Timeout)
	local LastMaxHealth = Humanoid.MaxHealth
	local LastHealth = Humanoid.Health
	
	Humanoid.MaxHealth = math.huge
	Humanoid.Health = math.huge
	
	task.wait(Timeout)
	
	Humanoid.Health = LastHealth
	Humanoid.MaxHealth = LastMaxHealth
end
1 Like