I need the player to teleport to another game when they click this button gui
function Click()
local TeleportService = game:GetService("TeleportService")
local gameID = 4991075396
end
script.Parent.MouseButton1Down:connect(Click)
I need the player to teleport to another game when they click this button gui
function Click()
local TeleportService = game:GetService("TeleportService")
local gameID = 4991075396
end
script.Parent.MouseButton1Down:connect(Click)
local TeleportService = game:GetService("TeleportService")
local gameID = 4991075396
local player = game.Players.LocalPlayer
function Click()
TeleportService:Teleport(gameID, player)
end
script.Parent.MouseButton1Down:connect(Click)
It's best to keep the variables that are going to remain constant on the outside of the function. Also, you will need to define player, so that the game knows who it needs to teleport when they click the button.
You then need to set up the statement that takes the TeleportService, and then teleports the player. The parameters used here are what game you want(gameID) and which player to teleport(player.)
Hope this helps!
local Player = game.Players.LocalPlayer -- Get player
local TeleportService = game:GetService("TeleportService")
local gameID = 4991075396
function Click()
TeleportService:Teleport(Player, gameID)
end
script.Parent.MouseButton1Down:connect(Click)
This is a local script btw Hope this helps lol
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
This did not work but there is no errors in the output??