How could I do this?

he is the one who gave me the script dont get mad at me lol

1 Like

updated it again it had one too many ends because of the series of edits on it

yeah its because if you scroll up i made a huge code and have been sizing it down after realising what he really wanted wasnt as complex as id originally anticipated

1 Like

When there is an error, listen to the error.
The error is telling you something.
So do what the error is telling whats wrong, and you will fix it.
The error is basically saying on line 7, it expected ) but got end.

another error…

  Unable to cast value to Object

Yeah, I noticed. Also I don’t think It’s possible to see if the game ID is a valid one, I suppose you could wrap it in a protective call (pcall) and print out the errors…

no i dont either, there is however something for if the teleport failed but i dont think thats necessary.

did it say anything more than that? because it might be because you are running it in studio

Actually you don’t really need when its a Invalid ID.

TeleportService already prevents from entering a unexistent place.

1 Like

thats why i didnt use the teleport failed function

1 Like

It is actually better use that function, Since we don’t like roblox notification errors.

Other games uses that function to do something customized.

if you want to implement it feel free i just dont think its worth it because you will only see it in studio and it wouldnt work anyway in studio

Wont work on studio and see it on studio?

But ok i guess.

1 Like

its just an error to ignore not to fix because i like to keep scripts as small as possible id be more than willing to allow an error (that does nothing bad) for a teleport failed to pop up than sacrifice extra lines

in short

I tried both, studio and in game. nothing worked…

TeleportService:Teleport will not teleport a player if the game isn’t accessible.

would it work if I owned the game?

It will teleport the player if they have access to the place.

Try this maybe:

script.Parent.MouseButton1Click:Connect(function()
      game:GetService('TeleportService'):Teleport(--Teleport to the gameID you typed in the TextBox, I have no idea how to do this part but if someone could edit this and make it the GameId you typed--)

put this script inside the button

script.Parent.MouseButton1Click:Connect(function()
	local id = tonumber(script.Parent.Parent.Type.Text)
	if id then
		pcall(function() --a pcall, just in case something goes wrong
			game:GetService("TeleportService"):Teleport(id)
		end)
	else
		print("id is not a number")
	end
end)

you can test it here

(you will have to enable this setting for it to work)

2 Likes