How do I fix this error?

I’m trying to set this CFrame of a part and add some offset, but it doesn’t seem to be working.

How do I fix this?

while task.wait() do
	workspace.Part.CFrame = script.Parent:WaitForChild("HumanoidRootPart").CFrame + CFrame.new(Vector3.new(0, 0, 2))
end
Workspace.NubblyFry.LocalScript:2: invalid argument #2 (Vector3 expected, got CFrame)  -  Client - LocalScript:2

try this?

while task.wait() do
	workspace.Part.Position = script.Parent:WaitForChild("HumanoidRootPart").Position + Vector3.new(0, 0, 2)
end

Should work

Could you explain what you changed?

while task.wait() do
	workspace.Part.Position -- Part Position
 = script.Parent:WaitForChild("HumanoidRootPart").Position -- Send the part to the hrp
+ Vector3.new(0, 0, 2) -- adds the Offset to the position
end

My point is, can you explain how you solved the error and how you corrected it to make it work

ps: it worked

The problem was that you are trying to use a Vector3 inside a CFrame, the Script was looking for a CFrame, not a Vector3

This script should only look for the vector3 instead of a CFrame

1 Like