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

How do i teleport player to new server using gui button?

Asked by 2 years ago

I wanted to make gui button that when activated will teleport player to the same game but new server

1 answer

Log in to vote
1
Answered by 2 years ago

You need to use TeleportService. First, place a localscript into your GUI. Inside the localscript, create a variable for the button. Then add a MouseButton1Up event and connect it to a function. Get the teleport service, and then run the function :Teleport() on the service, along with the game ID.

Your code should look something like this:


local button = script.Parent:WaitForChild("Frame"):WaitForChild("Button") -- put the path to the button here local teleportservice = game:GetService("TeleportService") -- get teleport service local ID = 523958034680934860 -- put your place ID here button.MouseButton1Up:Connect(function() -- add a mousebutton1 event here and connect it to a function teleportservice:Teleport(ID) -- teleports the player to the place end)
0
For some reason when i rejoin with this script it gives me error saying "Client initiated disconnect" kubapro213748 -13 — 2y
Ad

Answer this question