Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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)

1 comment

0

Thanks man, i really appreciate it ^^

This discussion is preserved as it was. New answers, comments, and votes are closed.