|
| 16 Aug 2016 09:14 PM |
^^Unquote, Output I have a mouseclicker in a part to make it move once clicked, but output reads, "Position is not a valid member of Model". |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2016 09:18 PM |
Code.
This siggy is copyrighted © |
|
|
| Report Abuse |
|
|
|
| 16 Aug 2016 09:21 PM |
| The error is very clear. Models' don't have a Position property. |
|
|
| Report Abuse |
|
|
mudkip99
|
  |
| Joined: 17 Jun 2008 |
| Total Posts: 3362 |
|
|
| 16 Aug 2016 09:38 PM |
If you want to move a model you'll want to give it a primary part and move it around using model:SetPrimaryPartCFrame(position)
|
|
|
| Report Abuse |
|
|
Zawie
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 6338 |
|
|
| 16 Aug 2016 09:56 PM |
You can just move a model with Model:MoveTo(Vector3) |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 11:32 AM |
| So like, Model:MoveTo(Xnumber,Ynumber,Znumber)? |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 17 Aug 2016 12:15 PM |
MoveTo takes a vector3 value as the argument.
|
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 12:16 PM |
| Model:MoveTo(Vector3.new(Xnumber,Ynumber,Znumber)) |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 01:10 PM |
| Okay, how do I write it so that the XYZ position is the position of another part so that when I move it I don't have to reset the position? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 17 Aug 2016 01:11 PM |
if x1 == x2 and y1 == y2 and z1 == z2 then
|
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 17 Aug 2016 01:12 PM |
Position is a vector3 value so if i understand your question correctly..
model:MoveTo(anotherPart.Position)
|
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 01:15 PM |
Unless of course you mean that you don't want to write from 0,0,0? then you can simply try model:SetPrimaryPartCFrame(Model.PrimaryPart.CFrame+Vector3.new(1,0,0)) -- moves it + 1 stud on x.
I would not use moveto because if there's an object in the way it can severely skew the position to as much as 1000 studs away from the intended position. |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 01:43 PM |
local doormodel = script.Parent.Parent.Parent.Parent local doorm = doormodel.DoorM local door = doorm.Door local closed = doorm.Closed local open = door.Open local clicker = door.ClickDetector
function onClicked()--open door:SetPrimaryPartCFrame(door.PrimaryPart.CFrame) end
clicker.MouseClick:connect(onClicked)
I clicked it and output says, "SetPrimaryPartCFrame is not a valid member of Part" |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 01:48 PM |
| it'd be doormodel:SetPrimaryPartCFrame(door.CFrame+Vector3.new(howevermany x studs,howevermany y studs,howevermany z studs)) |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 01:55 PM |
| Is the XYZ supposed to the position of the Primarypart? |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 02:20 PM |
| Wait so Vector3 would be not setting it to the position I want, but setting to how many studs it moves from it's current position? |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 17 Aug 2016 02:22 PM |
wat no you would add a vector if you want to do that
Formerly ToxicDominator - add 17,509 posts |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 02:24 PM |
| So it's setting the position? Even the command that CD was talking about? |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 02:24 PM |
"Vector3.new(1,0,0)) -- moves it + 1 stud on x."
-CD |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 17 Aug 2016 02:24 PM |
"Sets the CFrame of the PrimaryPart. All other parts in the model will also be moved and will maintain their orientation and offset respective to the PrimaryPart. This function will throw an error if no PrimaryPart exists for the Model."
Formerly ToxicDominator - add 17,509 posts |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 17 Aug 2016 02:26 PM |
that's because he's taking the current CFrame of the primarypart and adding a vector to it
Formerly ToxicDominator - add 17,509 posts |
|
|
| Report Abuse |
|
|
mudkip99
|
  |
| Joined: 17 Jun 2008 |
| Total Posts: 3362 |
|
|
| 17 Aug 2016 02:28 PM |
If you just want to move a model by X, Y, and z studs and not rotate it, you can just use TranslateBy:
model:TranslateBy(Vector3.new(X, Y, Z))
You don't need a primary part for that. |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 02:28 PM |
| Okay, so how do I set the position? |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 02:29 PM |
| Oh ^^ Except I do want to rotate it so would I use CFrame? |
|
|
| Report Abuse |
|
|
mudkip99
|
  |
| Joined: 17 Jun 2008 |
| Total Posts: 3362 |
|
|
| 17 Aug 2016 02:36 PM |
If you need it to rotate you'd have to set a PrimaryPart and use SetPrimaryPartCFrame. Here's an example that should rotate a model 90 degrees along its local Y axis.:
local degreesToRotate = 90
model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(degreesToRotate), 0)
|
|
|
| Report Abuse |
|
|