I've been trying to make a certain part of the player's body do damage when touched so I placed this script inside of that part of the player for it's StarterCharacter. When I noticed it wasn't working I took the StarterCharacter and copy and pasted it into the WorkSpace. I noticed that the one in the WorkSpace does work properly but what I also noticed is that a TouchInterest is being placed into the part of the player for the one in the WorkSpace but isn't being placed into the character when it's the active player. Why isn't a TouchInterest being placed into the active player? How do I get it to be placed into it? Thank you.

Here's the script.

local deb = false

function onTouched(hit)
	    if deb == true then return end
	    deb = true
        local human = hit.Parent:findFirstChild("Humanoid")
        if (human ~= nil) then
                human.Health = human.Health - 50
        end
        wait(2)
        deb = false
end
script.Parent.Touched:connect(onTouched)

1 comment

0

Bump