Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a GUI button game teleporter?

Asked by
lucas4114 607 Moderation Voter
9 years ago

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?...

0
You're welcome! EzraNehemiah_TF2 3552 — 9y
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. GamingZacharyC 152 — 6y

2 answers

Log in to vote
2
Answered by 9 years ago

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!

0
Thank you sooo much, my whole game is based on teleporting... :D lucas4114 607 — 9y
0
You mean IT WAS THAT SIMPLE TO TELEPORT THROUGH GAMES?! groovydino 2 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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.

0
No, I ment a game teleporter, to teleport to other games... lucas4114 607 — 9y

Answer this question