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

How do I make a GUI button game teleporter?

So, I've done it before with a part touch, now I'm trying to make a GUI button teleport you to a different game, I tryed changing the part touch script teleport to work for a GUI button click instead, so I made this but it didn't work:

function onTouched(click)
    local player = game.Players:GetPlayerFromCharacter(click.Parent)
    if player then
        game:GetService("TeleportService"):Teleport(228755269, player)
    end
end

 script.Parent.MouseButton1Click:connect(onTouched)

Help me?...

2 comments

0

You're welcome!

0

i'm looking to have a teleport, and this doesn't work (it has a loading GUI). The loading GUI is in ServerStorage. It is a LocalScript.

2 answers

✓ Accepted answer

Just make it a local script. Since with local scripts you can get the player easily. Also, MouseButton1Down does not return player sadly. Because if you're using a server script you can just do script.Parent.Parent.Parent.Parent and you get the player... Because with a local script the TeleportService already knows who to teleport(You), you don't need the whole player thing.


Finished Script

(Local Script)

script.Parent.MouseButton1Click:connect(function()
	game:GetService("TeleportService"):Teleport(228755269)
end)

I turned your 8 lined script into 3 lines.



Hope this helps!

2 comments

0

Thank you sooo much, my whole game is based on teleporting... :D

0

You mean IT WAS THAT SIMPLE TO TELEPORT THROUGH GAMES?!

s = game:service("TeleportService") id = 00000000 function onClicked() s:Teleport(id) end script.Parent.MouseButton1Click:connect(onClicked)

-- Make sure you make this a Local Script but still put this in a textbutton guied. And change the 0000000 to the game you want to be teleported to.

1 comment

0

No, I ment a game teleporter, to teleport to other games...

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