Is there such thing as a "IsStill" function that can be used for stuff like touched to see after a specific period of time if the function is still being triggered. For example a user could have touched a part. Then after 5 seconds you see if the user is still touching the part. If no such function exists how can I do this manually.
Is there such thing as a "IsStill" function?
1 answer
Hello.
No, there is no thing such as a "IsStill" function. However, you can create your own.
To do this, you will use the Touched event.
Here is some code:
script.Parent.Touched:connect(function(part)
end)
script.Parent.TouchEnded:connect(function(part)
end)
Now you must store the parts so that on TouchEnded you can decide which is the part and which isn't.
Now let's make a table, and a function.
Parts = {}
function IsStill(Part)
return false
end
script.Parent.Touched:connect(function(part)
end)
script.Parent.TouchEnded:connect(function(part)
end)
Since we made the table, we will store that part on the table, then verify if it isn't there anymore. This way, you can check if the existent part is on the Parts table.
Parts = {}
function IsStill(Part)
for i=1,#Parts do
if (Parts[i] == Part) then
return true
end
end
return false
end
script.Parent.Touched:connect(function(part)
table.insert(Parts, part)
end)
script.Parent.TouchEnded:connect(function(part)
for i=1,#Parts do
if Parts[i]==part then
table.remove(Parts, i)
end
end
end)
Hope this helps you out! ~luadotorg
3 comments
Nice! There is also is IsTouching function, I believe.
Hi, thanks for commenting. I cannot find "IsTouching" anywhere. I did find "GetTouchingParts" however, and that completely gone missing from me. It seems to work best with anchored parts.
Questions are answered a lot quicker thanks
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Use Touched and TouchEnded