Hello fellow devs, in this post I am asking for some help from you. I have a teleportation system, which teleports you to a different game and there is a queue system which works perfectly. But the thing that doesn’t work is the GUI (Leave Queue button), after the teleportation happens the GUI is still visible which shouldn’t be, even if you press it, it will still teleport you into the game all of that is fine. But I want it not to be visible.
I have tried fixing the issue with Remote Events sent to the client, same as Remote Functions but none of that worked, as well with a
game.Players.PlayerAdded:Connect(function(plr)
function which didn’t work as well.
Here is a video of what is happening: YouTube Video
This is the code I have (Server Sided):
local leaveButtonEvent = game.ReplicatedStorage.LeaveButton
local disableButtonEvent = game.ReplicatedStorage.DisableButton
local timerB = script.Parent.Timer
local countB = script.Parent.Count
local queue = {}
teleporting = false
local placeId = 13744393562
local maxPlayers = 1
local title = "Chapter 1"
wait()
countB.PlayerCount.TextLabel.Text = title.." ("..#queue.."/"..maxPlayers..")"
script.Parent.ProximityPrompt.ObjectText = title
local function updatePlayerCount()
countB.PlayerCount.TextLabel.Text = title.." ("..#queue.."/"..maxPlayers..")"
end
script.Parent.ProximityPrompt.Triggered:Connect(function(plr)
script.Parent.ProximityPrompt.Enabled = false
if plr.Character then
plr.Character:FindFirstChild("HumanoidRootPart").CFrame = script.Parent.Tp.CFrame
if teleporting == false then
local char = plr.Character
local duplicate = false
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
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)
leaveButtonEvent.OnServerEvent:Connect(function(plr)
if plr.Character then
plr.Character:FindFirstChild("HumanoidRootPart").CFrame = script.Parent.Parent.LeaveTp.CFrame
for i = 1, #queue do
if queue[i] == plr.Character.Name then
table.remove(queue, i)
updatePlayerCount()
script.Parent.ProximityPrompt.Enabled = true
end
end
end
end)
local function disableButton(plr)
disableButtonEvent:FireClient(plr)
end
if teleporting == true then
disableButton()
end
local function teleportPlayers(plr)
if #queue > 0 then
timerB.Time.TextLabel.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)
game.ReplicatedStorage.DisableLeaveButton:FireClient(plr)
repeat wait() until #queue <= 0
timerB.Time.TextLabel.Script.Disabled = true
timerB.Time.TextLabel.Text = ""
timerB.Time.TextLabel.TextColor3 = Color3.new(1,0,0)
teleporting = false
end
end
while wait() do
seconds = 15
for i=1, seconds do
seconds = seconds - 1
if timerB.Time.TextLabel.Script.Disabled == true then
timerB.Time.TextLabel.Text = "Teleporting in "..seconds.." seconds"
end
wait(1)
end
teleportPlayers()
end
(Client Sided):
game.ReplicatedStorage.LeaveButton.OnClientEvent:Connect(function()
script.Parent.Leave.Visible = true
script.Parent.Leave.TextButton_Roundify_12px.Visible = true
script.Parent.Leave.TextLabel.Visible = true
end)
script.Parent.Leave.MouseButton1Click:Connect(function()
game.ReplicatedStorage.LeaveButton:FireServer()
script.Parent.Leave.Visible = false
script.Parent.Leave.TextButton_Roundify_12px.Visible = false
script.Parent.Leave.TextLabel.Visible = false
end)
game.ReplicatedStorage.DisableButton.OnClientEvent:Connect(function()
script.Parent.Leave.Visible = false
script.Parent.Leave.TextButton_Roundify_12px.Visible = false
script.Parent.Leave.TextLabel.Visible = false
end)
If anyone has any idea of how this issue can be fixed, I would be really glad and thankful!