Queue Teleport Player with GUI not working

  1. So I’m trying to make the player teleport in and out a box as I’m working on a queue system, this and that system are seperate though.

  2. Though the teleporting inside works, the button is not working to have the player teleport out.

  3. I’ve tried fixing the paths and trying to search for any fixes, although it could be the facts that it is seperate from the script that handles queueing. Again, I’m super new to scripting.

I’ll answer any questions to fix this issue

local insidepart = script.Parent.playerin
local outsidepart = script.Parent.playerout

local player = game.Players.LocalPlayer

local prompt = script.Parent.Overhead.ProximityPrompt
local leavebutton = game.StarterGui.Queue.LeaveButton

-- Join Button
prompt.Triggered:Connect(function(player)
	player.Character.HumanoidRootPart.CFrame = insidepart.CFrame
end)

-- Leave button
leavebutton.MouseButton1Click:Connect(function(player)
	player.Character.HumanoidRootPart.CFrame = outsidepart.CFrame
end)

Video Example:
robloxapp-20230820-1329572.wmv (552.3 KB)

7 Likes

Maybe try this

local insidepart = script.Parent.playerin
local outsidepart = script.Parent.playerout

local player = game.Players.LocalPlayer

local prompt = script.Parent.Overhead.ProximityPrompt
local leavebutton = player:WaitForChild("PlayerGui").Queue.LeaveButton

-- Join Button
prompt.Triggered:Connect(function(player)
	player.Character.HumanoidRootPart.CFrame = insidepart.CFrame
end)

-- Leave button
leavebutton.Activated:Connect(function(player)
	player.Character.HumanoidRootPart.CFrame = outsidepart.CFrame
end)

If this doesn’t work check that the playerout is anchored if it is a part.

4 Likes

Unfortunately still nothing and now it won’t even teleport inside.

I also did check both of the parts and they are anchored

3 Likes

– Leave button
leavebutton.MouseButton1Click:Connect(function(player)
player.Character.HumanoidRootPart.CFrame = outsidepart.CFrame
end)

The first line where you connect to the MouseButton1Click Event: The MouseButton1Click event has no parameter so you are assigned nil to the player variable that you assigned above. So change you code to this and hopefully it will work.

local insidepart = script.Parent.playerin
local outsidepart = script.Parent.playerout

local player = game.Players.LocalPlayer

local prompt = script.Parent.Overhead.ProximityPrompt
local leavebutton = game.StarterGui.Queue.LeaveButton

-- Join Button
prompt.Triggered:Connect(function(player)
	player.Character.HumanoidRootPart.CFrame = insidepart.CFrame
end)

-- Leave button
leavebutton.MouseButton1Click:Connect(function()
	player.Character.HumanoidRootPart.CFrame = outsidepart.CFrame
end)
4 Likes

Although it won’t stop the player from teleporting inside, teleporting outside is still no good.

I did try adding prints to see what’s wrong and it won’t, detect the player click?

Video:

3 Likes

Hi again!

In the video you see that when you click on the “Leave Queue” Button it disappears. Where did you script that? I mean, the click gets registered and the button’s Visibility is set to false, by which script is this made? Maybe a local script with Parent set to the GUI button?

1 Like

Old one (You’ll read why):

local plr = 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)

I did notice this and although is isn’t what I wanted I came up with my own solution, instead of teleporting the player outside the box I made it so there’s a set location. Which did end up working.

Code for that:

local plr = game.Players.LocalPlayer
local outsidepart = game.StarterGui.Queue.playerout

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
	plr.Character.HumanoidRootPart.CFrame = outsidepart.CFrame
end)

I greatly appreciate your and Zerrox’s help though.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.