im trying to make a textbutton teleport to a parts position when the button is clicked ! any help is appreciated
local Button = script.Parent
local tproadz = game.Workspace:WaitForChild("tproads")
Button.MouseButton1Click:Connect(function(Player) -- this is where the error is
Player.Character:SetPrimaryPartCFrame(CFrame.new(tproadz.Position))
end)
The MouseButton1Click event does not give you the Player who clicked on the UI. To get the Player, this must be ran inside of a LocalScript, where you would get the player using game.Players.LocalPlayer.
The Client can teleport the Character anywhere it wants to since it has NetworkOwnership over it. This change will appear to all other players in the game.