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

How do you make a TextButton teleport the player?

Asked by 5 years ago

How are you able to make a TextButton teleport the player to a different game? This is what i've tried from a different one:

1local button = script.Parent
2button.Visible=true
3 
4local teleportService = game:GetService("TeleportService")
5 
6Test.MouseButton1Down:connect(function(player)
7teleportService:Teleport(4674197557)
8end)

Anything helps! Thanks!

0
Where did this `Test` come from? The MouseButton1Down is in your button, also you are using `connect`, which is deprecated. Use `Connect` instead. iiAmBetterThanYouHa 20 — 5y
0
Any errors? compUcomp 417 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

As you want to teleport a player you use teleport service https://developer.roblox.com/en-us/api-reference/function/TeleportService/Teleport

01local Players = game:GetService("Players")
02local TeleportService = game:GetService("TeleportService")
03 
04local placeId = 4674197557 -- replace here
05local userId = game.Players.LocalPlayer.UserId
06 
07-- find the player
08local player = game.Players.LocalPlayer
09 
10-- teleport the player
11script.Parent.MouseButton1Click:Connect(function()
12TeleportService:Teleport(placeId, player)
13end)
0
Please Accept My Answer If It Worked EnzoTDZ_YT 275 — 5y
0
well it did work but it keeps saying the place doesnt exist LinkZelda_Sage 16 — 5y
0
change placeId to the id of the place you want it to tp to EnzoTDZ_YT 275 — 5y
0
still LinkZelda_Sage 16 — 5y
0
as i am now unsuspended i can answer try it now sorry it took long EnzoTDZ_YT 275 — 5y
Ad

Answer this question