What do you want to achieve? Keep it simple and clear!
I want to teleport a player to a part
What is the issue? Include screenshots / videos if possible!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t thought of anything since it was working before
player.CharacterAdded:connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
wait()
if humanoid and hrp then
if stage.Value ~= 0 then
local part = workspace.Checkpoints:FindFirstChild(stage.Value)
hrp.CFrame = part.CFrame + Vector3.new(0, 1, 0)
end
end
end)
Not entirely sure, but it might mean that the WaitForChild isn’t working and hrp is returning nil, thus causing the script attempting to find the CFrame of nil. Not entirely sure though. Before you do hrp.CFrame add if hrp ~= nil then
first off is it a local script? if so then it will not work. As a local script only effects the player’s client. change the players pos with a normal script if it is a local script. Second: by the looks hrp.CFrame = part.CFrame + Vector3.new(0, 1, 0) you are trying to add on the the CFrame try setting it to a set CFrame hrp.CFrame = part.CFrame
player.CharacterAdded:connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
repeat wait() until humanoid ~= nil and hrp ~= nil
if humanoid ~= nil and hrp ~= nil then
repeat wait() until stage.Value ~= 0
if stage.Value ~= 0 then
local part = workspace.Checkpoints:FindFirstChild(stage.Value)
char:MoveTo(part.Position + Vector3.new(0, 1, 0))
end
end
end)
You should edit this to different functions that lets you teleport like character move to or something. If you dont wanna use it and keep use it then tell me. So i can find a solution for you.
as the error said, attempt to index nil with cframe, but it only works if it finds the root part. So, your “part” variable, doesn’t exist. We can’t help with that, because we have no idea about this part.