Hi! I'm currently doing something with the Roblox PathFindingService. I'm trying to CFrame a model so that it points to the point and then moves the model to that point. However, I'm running into an issue. When I try to set the CFrame of the primary part of the model I want to move I get an error.
Unable to cast Vector3 to CoordinateFrame
This is happening when I'm rotating the model to match the point I'm getting from the PathFindingService. The point is a Vector3 so I'm not sure why it's not working. Here is my script.
local Plane = game.Workspace.Plane
local PathFinding = game:GetService("PathfindingService")
local Start = Plane.PrimaryPart.Position
local End = Vector3.new(0, 0, 0)
local Path = PathFinding:ComputeSmoothPathAsync(Start, End, 500)
local Points = Path:GetPointCoordinates()
for _,v in pairs(Points) do
local Part = Instance.new("Part")
Part.FormFactor = Enum.FormFactor.Custom
Part.Size = Vector3.new(1, 1, 1)
Part.Position = v
Part.Anchored = true
Part.CanCollide = false
Part.Parent = game.Workspace
end
for _,v in ipairs(Points) do
repeat
Plane:SetPrimaryPartCFrame(Plane.PrimaryPart.Position, v)
Plane:SetPrimaryPartCFrame(Plane:GetPrimaryPartCFrame() + Plane:GetPrimaryPartCFrame().lookVector * 0.5)
wait()
until (v - Plane.PrimaryPart.Position).magnitude < 3
end
The issue is happening on line 20. Where it says Plane:SetPrimaryPartCFrame(Plane.PrimaryPart.Position, v). I'd also like to know too how I would go about rotating the model in steps so that it animates the rotating instead of just rotating to the point instantly. Thanks!

1 comment
You can use a BodyAngularVelocity to rotate what you want.