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

How can i move my rocket up?

Asked by 8 years ago

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)

1 answer

Log in to vote
0
Answered by 8 years ago

The problem is that when the script enters a whileloop, 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 positionproperty.

0
thanks for the answer but it still doesnt work, it gives me this error(21:45:38.489 - Cframe is not a valid member of Part 21:45:38.489 - Script 'Workspace.Missle Silo.Missle Control.SiloControls.RaiseMIss', Line 11) snipers0076 5 — 8y
0
Should be fixed. GoldenPhysics 474 — 8y
0
I fixed the problem but had to changed the code some. I had to replace CFrame with Position and it works fine snipers0076 5 — 8y
Ad

Answer this question