Unable to cast Vector3 to CoordinateFrame?
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.
01 | local Plane = game.Workspace.Plane |
02 | local PathFinding = game:GetService( "PathfindingService" ) |
03 | local Start = Plane.PrimaryPart.Position |
04 | local End = Vector 3. new( 0 , 0 , 0 ) |
05 | local Path = PathFinding:ComputeSmoothPathAsync(Start, End, 500 ) |
06 | local Points = Path:GetPointCoordinates() |
08 | for _,v in pairs (Points) do |
09 | local Part = Instance.new( "Part" ) |
10 | Part.FormFactor = Enum.FormFactor.Custom |
11 | Part.Size = Vector 3. new( 1 , 1 , 1 ) |
14 | Part.CanCollide = false |
15 | Part.Parent = game.Workspace |
18 | for _,v in ipairs (Points) do |
20 | Plane:SetPrimaryPartCFrame(Plane.PrimaryPart.Position, v) |
21 | Plane:SetPrimaryPartCFrame(Plane:GetPrimaryPartCFrame() + Plane:GetPrimaryPartCFrame().lookVector * 0.5 ) |
23 | until (v - Plane.PrimaryPart.Position).magnitude < 3 |
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!