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

My script only works when running the game under a certain circumstance for some reason? [SOLVED]

if script.Parent.Humanoid.Health < 10 then
	workspace.E:Destroy()
	script.Parent:Destroy()
end

this is my code. it works when I run it with the humanoid already at zero health, but if i kill the humanoid in-game and it's health is 0 it wont do anything.

(for context, script is in a character, E is a part in workspace)

1 answer

✓ Accepted answer

Well, it does not work as you forgot to add a forever loop. This should do it:


while true do wait()--So the script would not break if script.Parent.Humanoid.Health < 10 then -- now it checks all the time if the humanoid has died or not workspace.E:Destroy() script.Parent:Destroy() end end


1 comment

0

it works!! thanks!

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