Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to stop multiple touches?

Asked by 5 years ago

I'm currently working on a teleporter [like the one in flood escape] for a racing game. Where when you touch the invisible barrier it puts you inside the teleporter then adds your name in an array so the script can teleport you when the race starts. The problem is when the player touches I have it print ("Touch"), so in the output it prints: Touch(x30). I've tried a couple if statements so it will only fire touch once but nothing seems to work.

Heres the code:

Pa = {}

script.Parent.Touched:connect(function(part)
print("Touch")
local humanoid = part.Parent:FindFirstChild("Humanoid")
if humanoid then
table.insert(Pa, part.Parent.Name)
local root = part.Parent:FindFirstChild("HumanoidRootPart")
root.CFrame = script.Parent.Parent.Parent.MovingParts.Platform.CFrame + Vector3.new(0,5,0)
wait()
end
end)

Any idea's would be greatly appreciated.

0
Check out this great Roblox Wiki article: https://developer.roblox.com/articles/Debounce pidgey 548 — 5y
0
Thank you! Babyseal1015 56 — 5y
0
I tested it out and it works, the table only has one value in it. Thank you so much. Babyseal1015 56 — 5y

1 answer

Log in to vote
3
Answered by 5 years ago

Use a debounce, basically what it is, is just like a cooldown, set a boolean value called DB and make it false and when the touch event gets triggered, make an if statement seeing if DB == false thenand then do DB = true

0
Please read the op. That has already been suggested pidgey 548 — 5y
Ad

Answer this question