Ok, I know how to move the rocked up writing single code line by line, I want to learn how to move it up using something like i,v in pairs or something. The code that I would have to do would be like 500 lines long. I know there is a way that I can get the children of a model and move all of them up to a certain height and then stop I just cant find it.
I have a rocket in 2 parts.
the rockets path = (from the script) = (script.Parent.Parent.Parent.Rocket.Missle_Model)
the (Missle_Model) contains the 2 parts = ( Engine, Rocket)
the starting position of the Engine is = (30.507,88.2,1111.499) the starting position of the Rocket is = (-30.5,101.801,1111.5)
I want it to go up at an interval of .1 until the hit (117.2, and 130.801)
they have to go up at the same time
this is the code I have been messing around with ( I know its not right)
local E = script.Parent.Parent.Parent.Rocket.Missle_Model.Engine local R = script.Parent.Parent.Parent.Rocket.Missle_Model.Rocket function raise() wait(.5) if script.Parent.BarOne.Reflectance == 1 then while (E.Position.y < 117.2) do E.Position.y = E.Position.y + 0.1 while (R.Position.y < 130.801) do R.Position.y = R.Position.y + 0.1 wait(.1) end end end end script.Parent.ClickDetector.MouseClick:connect(raise)
if someone can help that would be really nice I have spent all day trying to find out how to do this and I cant find it anywhere.
P.S this is the code that I know how to do... it works but it would be very long.... and I have to do it 2 times one when it goes up and one when it goes down
(here is just a small piece that I started)
function raise() wait(.5) if script.Parent.BarOne.Reflectance == 1 then wait(.2) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,101.901,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102.1,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102.2,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102.3,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102.4,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102.5,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102.6,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102.7,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102.8,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,102.9,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,103,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,103.1,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,103.2,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,103.3,1111.5) wait(.1) script.Parent.Parent.Parent.Missle_Model.Engine.Position = Vector3.new(-30.507,88.2,1111.499) script.Parent.Parent.Parent.Missle_Model.Rocket.Position = Vector3.new(-30.5,103.4,1111.5) wait(.1) end end script.Parent.ClickDetector.MouseClick:connect(raise)
The problem is that when the script enters a while
loop, it'll complete the loop before it moves on. With what you're trying to do, its ok to put both in a single while
loop like so:
local modelRocket = script.Parent.Parent.Parent.Rocket.Missle_Model local rocketEngine = modelRocket .Engine --this just makes it slightly more readable local rocketBody = modelRocket .Rocket function raise() wait(.5) if script.Parent.BarOne.Reflectance == 1 then while (rocketEngine .CFrame.y < 117.2) do --only one while loop rocketEngine.CFrame = CFrame.new(rocketEngine.CFrame.X, rocketEngine.CFrame.Y + 0.1, rocketEngine.CFrame.Z) rocketBody.CFrame = CFrame.new(rocketBody .CFrame.X, rocketBody .CFrame.Y + 0.1, rocketBody.CFrame.Z) wait(.1) end end end script.Parent.ClickDetector.MouseClick:connect(raise)
CFrame
is more versatile for moving parts than altering the position
property.