So I have this script here which basically when Touched, will turn red, clone a random map from ServerStorage to a folder in the Workspace, and teleport the player to a part called "Part3". The problem is that only one person can press this button and be teleported to a map; the rest of the players have to wait until he completes the map or the timer (nuke) runs out. How could I use a delay function or something else to allow multiple people pressing the button and track the players on a table?
(A delay of about 5 seconds would probably help a lot considering players will not press a button at the exact same time)
Here is the full script:
local Teleport = "Part3"
local part = script.Parent
part.BrickColor = BrickColor.new("Bright green")
local playertable = {}
function Touch(hit)
if hit and hit.Parent and hit.Parent:IsA("Model") then
print("OK")
else
return
end
if part.BrickColor ~= BrickColor.new("Bright green") then
return
end
part.BrickColor = BrickColor.new("Bright red")
script.Parent.BillboardGui.Enabled = false
local mapstorage = game.Workspace:WaitForChild('nukeeasy')
mapstorage:ClearAllChildren()
local mapsinserverstorage = game:GetService('ServerStorage').NukeMaps.Easy:GetChildren()
local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
chosenmap = chosenmap:Clone()
chosenmap.Parent = mapstorage
print(hit)
print(hit.Parent)
print(hit.Parent:IsA("Model"))
print(chosenmap)
print(chosenmap:findFirstChild(Teleport))
this = true
if this == true then
wait(2) if hit and hit.Parent and hit.Parent:IsA("Model") and chosenmap and chosenmap:findFirstChild(Teleport) then
this = false
hit.Parent:moveTo(chosenmap:findFirstChild(Teleport).Position)
wait(1)
this = true
end
if chosenmap.Name == "WrWaRo" then
script.Parent.WrWaRo.Disabled = false
end
if chosenmap.Name == "SiSe" then
script.Parent.SiSe.Disabled = false
end
if chosenmap.Name == "SuSo" then
script.Parent.SuSo.Disabled = false
end
end
end
part.Touched:Connect(Touch)
Do not mind the if-then checks for chosenmap.Name, that is just another system.
Thank you!

3 comments
Have a bool variable called "IsPlaying". Make sure when you set this to true that it comes after your debounce. You'll use this to make sure that other functions know someone is playing.
If you want a table of players that are currently on the button then you could try using Region3. I don't see why you need this method though.
Titles that contain "Help!" make the question a bad question immediately.