This is my code.

    local part = script.Parent --part
`while true do`

    wait(0.05)

    part.Touched:Connect(function()
        local z = 0
        wait(1)
        z = z + 1
        part.TouchEnded:Connect(function()
            z = 0
        end)
        if z == 5 then
            print("got it")
        end
    end)
    end

I want it so if they are touching it for more then 5 seconds it should print got it, but I reserved no message in the output view, not even an error. I would really appreciate some help!!

4 comments

0

Don't use a loop for this; it's just going to keep setting up touched events every time the loop fires.

0

GetTouchingParts

0

what should I do then??

0

while #part:GetTouchingParts() > 0 do