Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How could I find if a Humanoid was touching a part?

Asked by 3 years ago

So, I put this code into a part:

part = script.Parent while true do if part.Touched then print("STOP TOUCHING ME!!!!!") end wait() if part.TouchEnded then print("Oh, Finally.") end wait() end

And it started printing infinitely because another part was touching it. Could you know how to help?

1 answer

Log in to vote
0
Answered by 3 years ago

Try using the event instead:

part.Touched:Connect(function(hitPart)
    if hitPart.Parent:FindFirstChildOfClass("Humanoid") then
        print("STOP TOUCHING ME!!!!!")
    end
end)
part.TouchEnded:Connect(function(hitPart)
    if hitPart.Parent:FindFirstChildOfClass("Humanoid") then
        print("Oh, Finally.") 
    end
end)
1
Cool, thanks :) Valkyrie1277 28 — 3y
Ad

Answer this question