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

Is this possible to do something like this with Touched event?

Asked by 4 years ago

Im trying to make something with Touched event like this;

Player will touch the part and wait 5 seconds without stopping touching the part, and then other part's transparency would be 1.

I mean if player touched the part and wait 3 seconds then stops touching it, function will not be triggered, but if he waits 5 seconds it will trigger the function. Can somebody explain how can i do this?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local part = game.Workspace.part -- your part you want
local i = 0
local f = true
part.Touched:Connect(function()
    f = true
    while f = true do
        i = i + 1
        if i = 5 then
            -- there's script when you make player transparent
        end
        wait(1)
    end
end)

part.TouchEnded:Connect(function()
    f = false
    i = 0
end)
0
Thanks man, i really appreciate it ^^ aSpecialGuy 18 — 4y
Ad

Answer this question