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

TouchEnded triggers while player is still on part?

When this player touches this pad the touchended function triggers, is there any ways to stop this?

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if isPlayerAlreadyInList(player) == false then
		local listlength = #nextup
		if listlength >= 3 then
			removeplayerfrompad(player)
		else
			table.insert(nextup,player.Name)
			table.insert(ready,0)
			padcolour()
			updateScreens()
			
		end
	end
end)

script.Parent.TouchEnded:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if game.Players:GetPlayerFromCharacter(hit.Parent) == player then
		if isPlayerAlreadyInList(player) == true then
			print(findItemPos(player.Name,nextup))
		end
	end		
end)

1 comment

0

I use a custom magnitude script that isn't 100% accurate, but detects what part a player is touching.

1 answer

The .Touched and .TouchEnded function are very stupid. If you stand on a part for too long, the TouchEnded function may fire. If you land on a part, sometimes the Touch function may not fire at all. I'd recommend you use a small Region3 or .magnitude, because .Touched really shouldn't be used for long term. Maybe ROBLOX was being a nitpicker when developing, and only considered the touch event, but not when someone keeps touching the part. Heck, you could probably even use :GetTouchingParts() on a player's legs, it's probably more reliable than the .Touched event. Just, don't use the .Touched event on a basepart. It's extremely unreliable.

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