I made this script so when the player jumps on an enemy AI's head the enemy will die. But it doesn't always work.
Such as: When the player jumps and jumps off on the enemy's head the enemy will not die. The player can stand on the enemy's head and it will take a few seconds for the enemy to die.
Is there a possible solution to this?
(Also since I'm a beginner I got some of this code from the Roblox wiki to detect if the thing touching the enemy's head is player and not anything else)
The script is placed inside the enemy's head.
(Explains the - script.Parent(head).Parent(enemy).Humanoid.Health = 0)
local Head = script.Parent local function handleTouch(otherPart) local character = otherPart.Parent local humanoid = character:FindFirstChild("Humanoid") if humanoid then script.Parent.Parent.Humanoid.Health = 0 end end Head.Touched:connect(handleTouch)