Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to I teleport a player to a game?

I am trying to Teleport a player using a ImgButton. But I don't see what is wrong with my script.

local Button = script.Parent
local teleportService = game:GetService("TeleportService")

function onClick()
	local Player = game.Players:GetPlayerFromCharacter(Click().Parent)
	if Player ~= nil then
		teleportService:Teleport(168955334,player)
	end
	
end
Button.MouseButton1Click:connect(onClick)

1 answer

Is this a LocalScript? If not, you should probably be using a LocalScript since you're dealing with Guis anyways.

If you are using a LocalScript, you can do this:

local Button = script.Parent
local teleportService = game:GetService("TeleportService")

function onClick()
	teleportService:Teleport(168955334)--Since you're using a LocalScript, you do not need the player
end

Button.MouseButton1Click:connect(onClick)

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.