Gantry player detection

Hello, I am scripting a gantry system. Players are given a passport at spawn and when they activate the tool, an animation of them reaching out and tapping their passport plays. I want to detect when a player is near the gantry and playing the animation, the trouble with that is the gantry is one-way, so how would I detect which side they are on and checking if the passport lands on the yellow pad (tap zone). I know I can use like region detection but was wondering if there way any easier way



1 Like

I guess I can detect when a passport touches the yellow pad and get the player from that and check if the player is playing an animation

Apply a state-management system to this. That should fix your problem. I wouldn’t try to over-complicate something so simple… draws attention away from priorities. You could send an event to the server before the animation plays, but that’s overkill.

What do you mean a state management system

A system that’s based on preserved state control. Allows you to manipulate actions based on states. For example if a user clicks a part w/ a clickdetector, a possible state could be:

local state = false

   if state then
      state = false
      state = true
      -- Do action

Hopefully, this is good enough to convey what a state is and how you could use it. If it’s not, I’d advise googling. Very helpful at times.

Isn’t that just a bool lmao “state management”

1 Like

Not exactly. Just a simple example I used.

You can use Region3 to make sure they are in a certain specified area when it is scanned. If they are, the gate opens, if not, the gate stays closed.

Here is more information about Region3 that may prove to be useful for you: Region3 | Documentation - Roblox Creator Hub

There are multiple functions of Workspace that allow you to detect what is inside a region. You could possibly make a system that iterates through all parts inside the Region, and if that part is a child of the “scanner player”'s character it would open. Read more about finding parts inside a region here: Workspace | Documentation - Roblox Creator Hub

Hope this proves useful!

1 Like

Yeah in my post I said I know I can use region detection, but then it would be easier if I check if the passport touches the pad and then check the passport “state” to see if the anim is playing

I think you should ignore what @sanjay2003 said with states, he seems like he was just trying to explain how to open and close the gantry which is not what you were asking for.

If you really want to use touch events without regions, you can probably just make it so a scanner is on one side and out of reach on the other side. Whenever the passport touches the scanner, the scanner would check the part to make sure it was a valid passport and open the gate. When the gate is closed, the sensor should be out of range from the other side.

Here would be some example code:

local Sensor = script.Parent:WaitForChild("Sensor")

    if hit.Parent.Name == "Passport" then -- hit is the handle, parent is the tool, so tool name would have to be "Passport"
        -- open gate for small amount of time

If you don’t want to require them to hold the passport while they walk through you could use the sensor to detect player character touches and open based on if a passport is inside the backpack.

Let me know if this helps!


Yep this is what I was going to do, thanks!