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

How can I make a TextButton teleport a player to another place?

Asked by 6 years ago
Edited 6 years ago

I'm trying to make it so when the player presses the TextButton, they would be teleported to a different place which is a side place of my game. However, it is obviously not working since I suck at coding. I checked Roblox Wiki and this is the best that I can do:

local PortalGui = script.Parent
local PortalFrame = PortalGui.PortalFrame
local PortalScrollingFrame = PortalFrame.PortalScrollingFrame

local TeleportService = game:GetService("TeleportService")
local World1ID = 1114619171
local Test = PortalScrollingFrame.TextButton

Test.MouseButton1Down:connect(function(player)
    TeleportService:Teleport(World1ID, player)
end)

This is the Roblox Wiki that I used.

Any help is appreciated!

1 answer

Log in to vote
0
Answered by
caoshen 96
6 years ago

What you have should work, however, replace FindService with GetService. If you use FindService and the service TeleportService doesn't already exist, it'll return nil, whereas GetService will create that service and return it.

I'd also imagine you'd have to actually be in a server for it to work (don't quote me on that though).

Hopefully that small fix resolved the issue for you!

0
It didn't really fix it, though nice try! marioblast1244 113 — 6y
Ad

Answer this question