Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i detect when a players health cahnges then heal them?

2 answers

✓ Accepted answer

There is a .Changed event. You would use it like so:

function changed()
	player.Humanoid.Health = 100
end

instance.Changed:Connect(changed)

2 comments

0

Just read the comment, if theres a HealthChanged event then you would replace .Changed with it.

0

The reason there is a HealthChanged event is because it includes the new Humanoid's health as a parameter, also, that script will change your health if ANYTHING changes in the Humanoid, which is incorrect..

You will use the 'HealthChanged' function as stated above. If for some reason you have the health higher than 100, this will set it to the maxhealth

game:GetService("Players").PlayerAdded:Connect(function(plr)

	plr.CharacterAdded:Connect(function(char)

		local Humanoid = char:FindFirstChildOfClass("Humanoid")
		
		Humanoid.HealthChanged:Connect(function()
			
			Humanoid.Health = Humanoid.MaxHealth
			
		end)

	end)





end)



This discussion is preserved as it was. New answers, comments, and votes are closed.