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

How to move a models children smooth?

Asked by
Nidoxs 190
9 years ago

Up to now no one has helped me with this because every time I try it it is dead jittery and buggy, PLEASE help me move a models children (acting as a door.) SMOOTHLY like when you have 2 models the left door and the right door they move the opposite directions here is what I have so far. :)

local Model = script.Parent.D1
local Model2 = script.Parent.D2

function Move()
    for Index,Part in pairs(Model:GetChildren()) do
        if Part:IsA("BasePart") then
                     for i=1,20 do 
    Part.CFrame = Part.CFrame*CFrame.new(0,0,0.5) 
wait()    
    end  
wait()
        end
 for Index,Part in pairs(Model2:GetChildren()) do
        if Part:IsA("BasePart") then
            for i=1,20 do 
    Part.CFrame = Part.CFrame*CFrame.new(0,0,-0.5) 
wait()    
    end  
end
end 
end 
end 


script.Parent.ClickDetector.MouseClick:connect(Move)


1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

You've almost got it! Where you see "wait", just add a number as a parameter. I suggest .1 or .01. The downside to the script below is that it's going to move "Model" first, then when it's finished, it'll move "Model2"

local Model = script.Parent.D1
local Model2 = script.Parent.D2

function Move()
    for Index,Part in pairs(Model:GetChildren()) do
        if Part:IsA("BasePart") then
                     for i=1,20 do 
    Part.CFrame = Part.CFrame*CFrame.new(0,0,0.5) 
    end  
wait(0.1)
        end
 for Index,Part in pairs(Model2:GetChildren()) do
        if Part:IsA("BasePart") then
            for i=1,20 do 
    Part.CFrame = Part.CFrame*CFrame.new(0,0,-0.5) 
    end  
wait(0.1)
end
end 
end 
end 

script.Parent.ClickDetector.MouseClick:connect(Move)
0
How do I do it so I can move both? Nidoxs 190 — 9y
Ad

Answer this question