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.
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