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

Move replica model with additions to the exact same place as another model?

Asked by
TomsGames 225 Moderation Voter
11 years ago

Model bc = bluecar Model ebc = editbluecar

ebc:MoveTo(bc:GetModelCFrame()) doesn't work as MoveTo uses Vector3.. But I also want the model to be rotated. Yet I am taking into account the cframe of a model is the center, it's the same size (a replica) just with an addition.

TY!

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
11 years ago

To move model1 to model2

01model1=Model
02model2=Model
03 
04local a=model1:GetModelCFrame()
05local b=model2:GetModelCFrame()
06local c=a*b:inverse()
07function getparts(m)
08    for _,v in pairs(m:GetChildren())do
09        if v:IsA("BasePart")then
10            v:BreakJoints()
11            v.CFrame=c*v.CFrame
12            v:MakeJoints()
13        end
14        getparts(v)
15    end
16end
17getparts(model1)
Ad

Answer this question