Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Player Teleportation only works in Studio?

Hello, I'm trying to code a Player Teleportation script for an OnClicked Gui to teleport to my game. The code is below.

function OnClicked()
	script.Disabled = true
    local player = script.Parent.Parent.Parent.Parent
    if player then
        game:GetService("TeleportService"):Teleport(361416851, player)
    end
end
 
script.Parent.MouseButton1Click:connect(OnClicked)

Why does this not work in a game? If someone can help me, that'd be great!

1 comment

0

Here is the game if you wanted to see it. https://www.roblox.com/games/723448353/test

1 answer

✓ Accepted answer

You're trying to shut down the script before you can do anything. Move line 2 down to line 5 and it should work. Good luck!

5 comments

1

I'd hate to say this but it still does not work and I have made sure the ID is correct. It says "Invalid Character to Teleport" in the Developer Console. Help again?

0

Okay, you may be using too many or too few .Parent's. Try subtracting one, and if that doesn't work, try adding one.

1

I had to add a Parent! I appreciate this!

0

If it's a LocalScript (which it mostly should be for a gui) you can use "game.Players.LocalPlayer" anyhow.

0

@JJ_B LocalScripts don't allow for TeleportService.

This discussion is preserved as it was. New answers, comments, and votes are closed.