function onClick(Click) local player = game.Players:GetPlayerFromCharacter(Click.Parent) if player then game:GetService("TeleportService"):Teleport(164893711, player) end end MouseButton1Click:connect(onClick)
What im trying to do is get this button to teleport to a place im not good with gui buttons
You should first of all use a local script so you can get the player a lot easier. Because GUI's are different for every client, you know the player that clicked it will always be the LocalPlayer
.
local player = game.Players.LocalPlayer local gui = script.Parent -- Location of teleport GUI button gui.MouseButton1Click:connect(function() game:GetService("TeleportService"):Teleport(164893711, player) end)
The only real error you had was in your connection line. You didn't declare which GUI was effected by the event MouseButton1Click
.