Will we ever see a better TouchEnded event?

It’s currently too hard to make an effective detection system to check if a part isn’t touching something anymore without taking a huge performance hit. As mentioned in many threads, TouchEnded is unreliable and causes unwanted results.

The most common situations where the problems have occurred are during repetitive TouchEnded event firing and high velocity exiting of a part.

Will we ever see an improved version of this event?

Some threads where this is mentioned:

10 Likes

TouchEvents have been a bit of an annoyance for me aswell.

What I have done for some activation scripts is measure distance between the players torso and the part. But I am sure there are better ways out there.

From all the recent updates Roblox is pushing out, I think Touched Event is for sure something they are most likely working on. I know of some alternatives for the Touched event, the repetition can be stopped with a script.Disabled statement, something like that. But I haven’t seen any performance issues for PC’s with Intel Core i3 and higher, ( as from asking friends ).

2 Likes

One thing I would love to see with touched events is a way to detect a player touching a brick welded to them. This is something which is not currently possible and I have had to resort to using GLUE, (I know glue) to glue a brick on top of the welded brick which I am attempting to detect hits from. I would be very grateful should Roblox come up with an alternative to the touched event though I don’t see it coming any time soon. Something I would also like to see is a way to measure a touched events position from said X,Z on a brick

1 Like

TouchEnded is an event?

Well it doesn’t exactly make sense as a function :smile:

Well, I didn’t know that you could check for when it ended. Just when it touched.

If you attempt to make a pad of some sort using Touched and TouchEnded, its practically impossible no matter how many debounces or whatnot you add from what Ive seen with my own attempts in the past

Yeah. I wish it wouldn’t count as touched EVERY time the player moves in the part.

3 Likes

I find that even if a part is sitting still inside of an object, it keeps touching untouching touching untouching etc.

2 Likes

It’s definitely a pain.

There are ways to prevent this, again if the player makes contact with it once, make it a local script with a statement:

--example script
script.Parent.Touched:Connect(function(hit)
	local human = hit.Parent:FindFirstChild("Humanoid")
	if human ~= nil then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			plr:Destroy() -- just an example
                   wait(.2)
                     script.Disabled = true --where it goes down, disables the script causing it not to go more than once
				end
	end
end)

Lets say we need to detect a player stepping off as well? Using this method we would be stuck in an endless loop of touched and touch ended loops as the scripts are enabled and disabled or am I thinking improperly? Local scripts would also require devs to use remotes which could also bring up security issues since whenever I am hooking up a touched event it serves a server purpose

You are thinking improperly, as when it is touched ONCE it will turn off the script automatically unless you add a statement of how it will re-enable the script ( most of the time ending up having to make a completely seperate script )
for example:

script.Parent.Touched:Connect(function(hit)
	local human = hit.Parent:FindFirstChild("Humanoid")
	if human ~= nil then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
			plr:Destroy() -- just an example
                  print('Script is going to re-enable')
 wait(.2)
             local script = game.Workspace.YOURMODELNAME.YOURPARTNAME.YOURSCRIPTNAME
                 script.Disabled = false
         end
	end
end)

( had to edit it due to a problem )

Yes I understand that but thats what Im questioning, If I was to need to have the script be re-enabled to be reused by another player after the touch has ended.

If the event fires multiple times, you can simply disconnect it:

local TouchedEvent
TouchedEvent = Part.Touched:Connect(function(Hit)
    if Hit and Hit.Parent then
        local TouchEndedEvent
        TouchEndedEvent = Part.TouchEnded:Connect(function(Hit)
            TouchEndedEvent:Disconnect()
            TouchedEvent:Disconnect()
            --Do Stuff
        end)
    end
end)

You can easily just make the script a LocalScript so it happens locally, it wont be a serverside edit so others still have access to the brick!

Im not saying you have not figured out an alternative which may help people out but lets take a look at again the pad scenario with games which use pads to create a matchmaking system in games such as swords. Many have had to result to using region3 to solve this issue. Players must stand on pads to get matched with an opponent and using this would still cause issues as this is something which would be handled on the server and need to wait till the matchmaking is found and the round is over to re-allow players to register on the pads for their fights. There is no set time to wait before being able to re-enable the script unless someone would do it after the matchmaking has finished but lets say someone steps on then steps off, their hit would still be registered for .2 seconds after using your method which would work since it would be reenabled but if they are just waiting on the pad as you re-enable the touch event it would still cause issues while players are waiting.

My method would work , but the way it would re-enable is a COMPLETELY separate part. If you want I can go more in depth, like with values ect. Finding you a more efficient way. Would you like me to do this?

What Im explaining is that your method although it works is a little hacky and should not be required in order to be able to use the touch/touchended events. I understand what you are trying to say completely but its just not something we should be forced to do in order to get touched events working.

1 Like