Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

is it possible to re-position a model ?

Asked by 9 years ago

there's models inside of models its a tycoon.. i want to put it in server storage then clone it and re-position it with a script

1
There is a method called 'Model:GetModelCFrame()', which will get the CFrame of a 'Model' type instance, however, to get it's Position, you'll need to add '.p' to the method, also, yes, the Method's Position can be changed. TheeDeathCaster 2368 — 9y
0
could you give me an example ? Layfonex 0 — 9y
0
model:SetPrimaryPartCFrame() or TranslateBy() or MoveTo() Goulstem 8144 — 9y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

There are many ways you can go about Re-Positioning a model. But i'll explain how to get the current Position of a model, and the top 3(In my opinion) ways to re-position a model.


You can get the current Position of a model two ways. The first way being using the GetPrimaryPartCFrame method, and the second being using the GetModelCFrame method.


1) The GetPrimaryPartCFrame() method will return the Model's PrimaryPart CoordinateFrame, which is the proper term for CFrame. If PrimaryPart is nil(non-existant) then it will return an error in the output.



2) The GetModelCFrame() method will return the Model's average CFrame, which is a CFrame computed by using all the parts in the model's CFrames' and Size Extents. This way is much more accurate as far as the real CFrame of the Model than using choice 1.





Top 3 ways to position the model;


1) The SetPrimaryPartCFrame() method takes an argument which should be the CFrame you would like to reposition the object to. This will return an error if the PrimaryPart of the model is not set. This will overlap objects.

model:SetPrimaryPartCFrame(CFrame.new(10,0,0))


2) The TranslateBy() method takes an argument wich should be the offset point of which to CFrame the model from it's current Position, using a Vector3. This will overlap objects as well. For example, if I wanted to move the model 10 studs to the right from it's current position I would do..

model:TranslateBy(Vector3.new(10,0,0))

A good way to use this for CFraming the model would be finding the difference in CFrames, then using that as the offset, or arguments for the method.



3) Lastly, the MoveTo() method takes an argument which should be the Position you'd like to move the model to, in the form of a Vector3. This will not overlap objects, it will snap above any object in the way.

model:MoveTo(Vector3.new(10,0,0))
Ad

Answer this question