Game wont put player in TeleportQueue

Hello, i want to make a ‘Horror’ style game. With a lobby that has teleporters in them so you can join a game. The problem i have is the game wont put me in Queue after i am done holding in the proximityprompt that’s supposed to get me in the queue.

Here is a video:

Here is my RemoteEvent:
image

Below here is the code finding place in the Handler script in this foto:
image

local TeleportService = game:GetService(“TeleportService”)
local leavebuttonevent = game.ReplicatedStorage.LeaveButton
local billboard = script.Parent.Overhead.BillboardGui
local Queue = {}
teleporting = false

–configuration
local PlaceID = 16302355375
local maxplayers = 1
local title = “Playtime Experience”

wait()
billboard.Frame.PlayerCount.Text = title…" (“…#Queue…”/“…maxplayers…”)"
script.Parent.Overhead.ProximityPrompt.ObjectText = title

local function updatePlayerCount()
billboard.Frame.PlayerCount.Text = title…" (“…#Queue…”/“…maxplayers…”)"
end

script.Parent.Overhead.ProximityPrompt.Triggered:Connect(function(plr)
if plr.Character then
if teleporting == false then
local char = plr.Character
local duplicate

		for i=1, #Queue do
			if Queue[i] == char.Name then
				duplicate = true
			end
		end
		
		if duplicate == false then
			if #Queue < maxplayers then
				table.insert(Queue, char.Name)
				leavebuttonevent:FireClient(plr)
				updatePlayerCount()
			end
			
			plr.CharacterRemoving:Connect(function(char)
				for i = 1, #Queue do
					if Queue[i] == char.Name then
						table.remove(Queue, i)
						updatePlayerCount()
					end
				end
			end)
				
		end
		
	end
end

end)

leavebuttonevent.OnServerEvent:Connect(function(plr)
if plr.Character then
for i = 1, #Queue do
if Queue[i] == plr.Character.Name then
table.remove(Queue, i)
updatePlayerCount()
end
end
end
end)

local function TeleportPlayers()
if #Queue > 0 then
billboard.Frame.Time.Script.Disabled = false

	local players = {}
	
	for i=1, #Queue do
		if game.Players:FindFirstChild(Queue[i]) then
			table.insert(players, game.Players:FindFirstChild(Queue[i]))
		else 
			table.remove(Queue, i)
		end
	end
	
	local server = TeleportService:ReserveServer(PlaceID)
	teleporting = true
	TeleportService:TeleportToPrivateServer(PlaceID, server, players)
	repeat wait() until #Queue <= 0
	billboard.Frame.Time.Script.Disabled = true
	billboard.Frame.Time.Text = ""
	billboard.Frame.Time.TextColor3 = Color3.new(1,0,0)
	teleporting = false
	
end

end

while wait() do
seconds = 25
for i=1, seconds do
seconds = seconds - 1
if billboard.Frame.Time.Script.Disabled == true then
billboard.Frame.Time.Text = "Teleporting in "…seconds…‘seconds’

	end
	wait(1)
end
TeleportPlayers()

end


Here is my local script:
image
local player = game.Players.LocalPlayer

game.ReplicatedStorage.LeaveButton.OnClientEvent:Connect(function()
script.Parent.LeaveButton.Visible = true
end)

script.Parent.LeaveButton.MouseButton1Click:Connect(function()
game.ReplicatedStorage.LeaveButton:FireServer()
script.Parent.LeaveButton.Visible = false
end)


Here is some useless script:
image

2 Likes

Have you tried this game in the Roblox Player because you cannot teleport to other games in Studio? If the Roblox Player doesn’t work, another bug that Roblox has is sometimes scripts will only work if the game is public.

1 Like

It doesnt seem to work when i publish it and play it. i have tried alot but cant seem to find the solution

2 Likes

so if you guys find a solution please comment it.