I’m trying to make it where when a player clicks a button they teleport to a certain location. I’m new to scripting and need some help. This is what I have so far and its giving me errors:
local gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").ImageLabel
local TouchDestination11 = game.Workspace:WaitForChild("TouchDestination11")
function onClicked(player)
if gui.Visible == true then
player:FindFirstChild("HumanoidRootPart").CFrame = TouchDestination11.CFrame
end
end
workspace.coin.ClickDetector.MouseClick:Connect(onClicked)
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local gui = script.Parent
local TouchDestination11 = game.Workspace:WaitForChild("TouchDestination11")
function onClicked()
Player.Character:PivotTo( TouchDestination11.CFrame)
end
workspace.coin.ClickDetector.MouseClick:Connect(onClicked)
What the above script shows should work. The issue with your script was you were attempting to get the HumanoidRootPart inside the Player object, and not the Player’s Character model. Which is fixed by referencing Player.Character.