Leg0brick
|
  |
| Joined: 24 Jul 2012 |
| Total Posts: 651 |
|
|
| 20 Aug 2015 11:36 PM |
I'm working on a script that takes all the parts in a model and moves them 1 stud one way, but I'm getting a strange error on line three. "bad argument #2 to '?' (Vector3 expected, got CFrame)" Here is the code:
for name, child in pairs(workspace.Truck1:GetChildren()) do if child:IsA("BasePart") then child.CFrame = child.CFrame + CFrame.new(0,0,10) end end
|
|
|
| Report Abuse |
|
|
Qaynar
|
  |
| Joined: 01 Feb 2015 |
| Total Posts: 486 |
|
|
| 20 Aug 2015 11:39 PM |
CFrame you have to do child.CFrame = CFrame.new(child.CFrame.X, child.CFrame.Y, child.CFrame.Z + 10) |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 20 Aug 2015 11:40 PM |
You can't add two CFrames, so add a Vector3 to that CFrame instead:
child.CFrame = child.CFrame + Vector3.new(0,0,1) |
|
|
| Report Abuse |
|
|
Leg0brick
|
  |
| Joined: 24 Jul 2012 |
| Total Posts: 651 |
|
|
| 20 Aug 2015 11:41 PM |
| Thank you both very much! It works now! |
|
|
| Report Abuse |
|
|
Vortilis
|
  |
| Joined: 06 Jul 2014 |
| Total Posts: 14163 |
|
|
| 20 Aug 2015 11:42 PM |
i thought it was obvious enough from the error? for i, v in pairs(game.Workspace.Truck1:GetChildren()) do if v:IsA("Part") then v.Position = v.Position + Vector3.new(0,0,10) print("Vortilis is awesome") end end |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2015 11:52 PM |
| With CFrame it is CFrame * CFrame (it doesnt multiply, it adds) |
|
|
| Report Abuse |
|
|