How can i make a ui teleport the player too a part when its clicked

lemme look

heres the error
Players.IT1024.PlayerGui.PauseMenu.PauseFrame.ImageButton.LocalScript:4: attempt to index nil with ‘CFrame’

did you change YourPart Variable Path to your Path?

yes i changed the YourPart to SpawnPart

it must look like this

game.Workspace.SpawnPart
2 Likes

yes thats what it looks like

Is your Part in workspace without any folders?

local Player = game.Players.LocalPlayer
local Character = Player.Character

script.Parent.MouseButton1Click:Connect(function()
Character:WaitForChild("HumanoidRootPart").CFrame = game.Workspace:WaitForChild("SpawnPart").CFrame
end)

theres no folder its in workspace

can you show me your explorer?

Maybe the problem is that you are trying to teleport from a local script so maybe try making a remote event and teleporting it from the server side

the character may not exist yet

local Character = Player.Character or Player.CharacterAdded:Wait()

still doesnt work

Did you try this @IT1024 ?

explorer is just SpawnPart in workspace
the ui is a little more complicated
image
the backtohubworld ui is the teleport button

Make a RemoteEvent in ReplicatedStorage
LocalScript (Inside your GUI Button) :

script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer()
end)

ServerScript (Inside ServerScriptService)

local YourPart = game.Workspace.SpawnPart
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr)
plr.Character.HumanoidRootPart.CFrame = YourPart.CFrame
end)
3 Likes

it works! tysm

3 Likes