So i made a boss fight where you have to position yourself so that when the enemy summons a spike, it impales itself dealing damage but if you get hit by it, you take damage.
The issue here is that damaging players working but damaging itself is not
I don't understand why it's not.
there is a value called HP inside the enemy model the script is inside the enemy model spike is defined as the summoned spike earlier in the code which works fine
Code:
local hit = false
local behit = false
spike.Touched:Connect(function(part)
if game.Players:FindFirstChild(part.Parent.Name) then
if hit == false then
hit = true
part.Parent.Humanoid.Health = part.Parent.Humanoid.Health - (15+(level*5))
end
end
if part.Parent == script.Parent then
if behit == false then
behit = true
script.Parent.HP.Value = script.Parent.HP.Value - math.random(50,750)
end
end
end)
Issue has been resolved, check comments to see how.

17 comments
Any errors in output?
nope
It can't damage the boss completely?
nope, it takes 0 damage but players can take damage
Where is this script located? A model, the boss, or the spike?
it's inside the boss as stated in the question
Is it possible to show the whole script? It doesn't seem to have any problem here.
the rest of the script works fine, it's this section that has the problem
Try to print something before
if part.Parent == script.Parent thenand after it so we can see where the script stopped.it seems like it doesn't even register it touching the boss
the touched event does not fire when it touches the boss, confirmed through print statements
Is the spike a model?
it is a meshpart
Maybe this can help you, https://devforum.roblox.com/t/touched-event-not-firing/432802
oh so it's just roblox's dumb touched function
Or you should say it is Roblox MeshPart fault?
ok so i unachored the spike and it actually works fine now. it even gave it a cool falling down animation without it tipping over, now how do i close this question?