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

Is there such thing as a "IsStill" function?

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.

1 comment

0

Use Touched and TouchEnded

1 answer

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

0

Nice! There is also is IsTouching function, I believe.

1

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.

0

Questions are answered a lot quicker thanks

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