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

How Do I Make a part visible if a player reaches a certain health?

I've been making a game where when you reach say, 75 health or less, blood will appear. Here is the script:

if script.Parent.Parent:WaitForChild("Humanoid").Health == 0 then
	script.Parent.Parent.Knife.Transparency = 0
end
if script.Parent.Parent:WaitForChild("Humanoid").Health <= 25 then
	script.Parent.Parent.Blood.Decal.Transparency = 0
	script.Parent.Parent.Blood.Decal2.Transparency = 0
end
if script.Parent.Parent:WaitForChild("Humanoid").Health <= 75 then
	script.Parent.Parent.Blood2.Decal.Transparency = 0
end

2 comments

0

1 script.Parent.Parent:WaitForChild("Humanoid").HealthChanged:Connect(function(health) 2 if health == 0 then -- put what health you want to detect here 3 --code here 4 end 5 end)

0

h

2 answers

You can use the event "Health Changed" instead of making a if then statement first.

Here is a format:

script.Parent.Parent:WaitForChild("Humanoid").HealthChanged:Connect(function(health)
if health == 0 then -- put what health you want to detect here
--code here
end
end)

Tell me if this works, try it!

2 comments

0

oh ok sry for the late respone

0

still doesnt work

Try this

script.Parent.Parent:WaitForChild("Humanoid").Changed:Connect(function() --This detects whenever something in the humanoid changes
	if script.Parent.Parent:WaitForChild("Humanoid").Health == 0 then
		script.Parent.Parent.KnifeTransparency = 0
	end
end)

script.Parent.Parent:WaitForChild("Humanoid").Changed:Connect(function()
	if script.Parent.Parent:WaitForChild("Humanoid").Health <= 25 then
		script.Parent.Parent.Blood.Decal.Transparency = 0
		script.Parent.Parent.Blood.Decal2.Transparency = 0
	end
end)

script.Parent.Parent:WaitForChild("Humanoid").Changed:Connect(function()
	if script.Parent.Parent:WaitForChild("Humanoid").Health <= 75 then
		script.Parent.Parent.Blood2.Decal.Transparency = 0
	end
end)

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