I made a barrier gate with animation but I would like to make it to go only 1 person at a time.
Here is a script:
local debounce = false
script.Parent.Touched:connect(function(p)
if p.Parent.Name == "Ticket" and debounce == false then
debounce = true
script.Parent.Parent.DL.Motor.DesiredAngle = 1.5
script.Parent.Parent.DR.Motor.DesiredAngle = 1.5
wait(5)
script.Parent.Parent.DL.Motor.DesiredAngle = 0
script.Parent.Parent.DR.Motor.DesiredAngle = 0
wait(5)
debounce = false
end
end)
So, what should I do like if someone bypasses and I would like to make person not glitching. When they tries, they should be respawned or put back and appearing the GUI not to glitch, etc.
You want the bypass and checks to be done on the server. As a client can easily exploit the code on a local script.
Also, you can have the server handle the animations and whatever else needs to be done. Then, you can simply have the server switch a boolean to allow another user to bypass. The debounce can be used as the boolean to allow one person at a time.
No, if the code is on a server script, they cannot exploit it. Only local scripts can be exploited. This is getting confusing. You two look like twins.
script.Parent.Touched:connect(function(p)
if (player has ticket and debounce == false) then
debounce = true -- This will prevent multiple players with tickets to pass at once.
-- Your player passing code here
debounce = false -- Allow the next player to pass
end
end)
You also have to check if the part that touched the gate belongs to a player character.
Then yes, you can do the following: if (p.Parent:FindFirstChild("Humanoid") and p.Parent:FindFirstChild("tickettoolname") and debounce == false)
That checks if the part that touched the gate deblongs to a player character, and if they have a ticket in their hand, and if no one is passing through the gate at the time they touched it.