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)
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)