I Need help on How to Teleport to a Place instead of a Game

so I’m Currently working on a Game with a menu that Teleports to the Main Game but I’ve been having Issues while Scripting

the Script won’t Teleport and I’m Very New to coding and Have tried Learning on Several other Platforms but they are for a Game not a Place in a Game

local RealCityX = ScreenGui.RealCityX
local TeleportService = game:GetService("TeleportService")
local Player = game.Players.LocalPlayer

local PlaceID = 10975225421

RealCityX.MouseButton1Up:Connect(function()
	TeleportService:Teleport(PlaceID, Player)
end)

Nothing seems wrong there. Are you using a LocalScript?
Try using Activated instead of MouseButton1Up?

Also where is the ScreenGui variable declared?

No, you must teleport the Player object not the Character.

1 Like

Yes I am using a LocalScript is that the Issue?

Excuse me, sorry I was taking reference from another script

Nope, it just wouldn’t run if it was a normal Script.
Is the ScreenGui variable defined anywhere?

Try changing the function event to MouseButton1Click

yes its used for the Gui Parent

Alright, I’ll try that out right now

Do keep in mind teleports do not work inside of Roblox Studio.
Are there any errors in Roblox Studio’s output? In the developer console when you press F9 in-game?

Yes, like @Maximum_ADHD said you have to use teleport service via client and not in-studio testing

I Used it outside of Studio, so thats not the issue

It did not work, still in the same issue

Alright then, try this:

local RealCityX = game.StarterGui.ScreenGui.RealCityX
local TeleportService = game:GetService("TeleportService")
local Player = game.Players.LocalPlayer

local PlaceID = 10975225421

RealCityX.MouseButton1Click:Connect(function()
	TeleportService:Teleport(PlaceID, Player)
end)

it also did not work, Do I Have to make the Game Public?

Yes, you do, and the starting place as well if it isn’t already

did not work, I don’t know how to solve this

Ok, It’s fine we will figure it out, is RealCityX a text button or some sort of button?

its the Place Name, so the Script could Teleport it to the Specific Place

No I mean this line, what is RealCityX?