Hi so i tried making a battle royale game in roblox but i have some issues heres the script. Okay so what im trying to do is try to stop my script from looping too much like when you press e near a mathmaking place u will be teleported in 10 seconds but the loop is looping too fast so it crashes the game when its teleporting players. Local script is further down
while true do
local Teleporters = {}
local TS = game:GetService("TeleportService")
local code = TS:ReserveServer(5970897194)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(Player, Input)
if Input == "Enter" then
Player.Character:MoveTo(workspace.TpPart2.Position)
table.insert(Teleporters,Player)
script.Parent.BillboardGui.Players.Text = script.Parent.BillboardGui.Players.Text.." "..#Teleporters
for i = 10,0,-1 do
script.Parent.BillboardGui.TextLabel.Text = i
wait(1)
end
for i, v in pairs(Teleporters) do
end
TS:TeleportToPrivateServer(5970897194,code,Teleporters)
table.clear(Teleporters)
elseif Input == "Exit" then
for i = 1, #Teleporters do
if Teleporters[i] == Player then
table.remove(Teleporters, i)
end
end
Player.Character:MoveTo(workspace.TpPart.Position)
end
end)
wait()
end
wait()
Local Script
local UIS = game:GetService("UserInputService")
local Exit = false
UIS.InputBegan:Connect(function(k,p)
if p then return end
if k.KeyCode == Enum.KeyCode.E then
if Exit == false then
if (game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Position - workspace.VectorPart.Position).Magnitude then
game.ReplicatedStorage.RemoteEvent:FireServer("Enter")
end
else
game.ReplicatedStorage.RemoteEvent:FindFirstChild("Exit")
end
end
end)

2 comments
Please describe your errors, what the script is supposed to do and how you're trying to accomplish it. Right now I have no idea what is wrong with it
Okay so what im trying to do is try to stop my script from looping too much like when you press e near a mathmaking place u will be teleported in 10 seconds but the loop is looping too fast so it crashes the game when its teleporting players