Help with scripting a rocket

  1. What do you want to achieve? I basically have some rockets that I want to launch but I can’t figure out how to properly complete this.

  2. What is the issue? I have tried many solutions such as… (see question 3), but they all have failed to work or have seemed too much of a hassle. I am sure there is an easier way of accomplishing this.

  3. What solutions have you tried so far? I have tried bodyforce but it doesn’t always go to plan and it seems too inconvenient. CFrame seems like the best solution but my rockets just won’t work with CFrame.

Below is my script to launch the starhopper rocket I made. I have a GetMass script in there so I could figure out what force to put on the rocket. It is messy and probably can be done more easily; with less of a hassle. If I’m wrong, please let me know :slight_smile: Thanks for any help!

Game: SpaceX South Texas Launch Site (Not Working On) - Roblox

-- local force = script.Parent.BodyForce



wait(4)

force.Force = Vector3.new(0,5874875,0)
print("up")

wait(7)

force.Force = Vector3.new(-680922.565,5447380.52268,0)

print("left")


wait(3)

force.Force = Vector3.new(680930.700,5447380.52268,0)
print("right")

wait(2)

force.Force = Vector3.new(0,5447380.52268,0)

wait(16)

force.Force = Vector3.new(0,5447380.60000,0) 
print("slow")

wait(2)

force.Force = Vector3.new(0,0,0)
print("MECO")

local sound = game.Workspace.Starhopper
local fire = game.Workspace.Starhop.Emitter.ParticleEmitter
local launch = game.Workspace.Starhop.Primary.Launch

sound:Stop()
fire.Enabled = false
1 Like

Hmm, if the rocket is a model you could also use Model | Documentation - Roblox Creator Hub or Model | Documentation - Roblox Creator Hub and update the y position with a loop. Although I recommend using BodyVelocity | Documentation - Roblox Creator Hub

1 Like

Alrighty. I’ll give it a try. Thanks!

If you want it to go an exact distance in 1 second you set the force to be the movers mass multiplied by gravity multiplied by the amount of distance you want to cover in studs. I checked out your game and it seems you want it to follow a certain path however. I would recommend then using bezier curves. image4

3 Likes

Thanks! I’ll give this a try too.

Hi again. I have never used bezier curves before so how would I get this to work with my rockets? I found and watched your tutorial on youtube and I’ve read a few things but I still don’t understand how I would bring this into Roblox. Thanks again for any help :slight_smile:

Basically you set control points to shift its orbit

Learn projectile motion it is one option I think so:

I dont know if you want a normel rocket it would be like that if you want a space x it would be like the second picture but its the same just the second rocket goes down and the first rocket goes mor up

and then you set the gravity of the first rocket, the second rocket goes then faster.

Ofcourse u can make the first rocket straight more in y-axis

so when a = 0 then you set the rocket gravity like as you would be in the space. and the second rocket goes down.

you can configure that.

Thanks! I will look into this.

could you make my comment solved or what do you still need :D? What should I still help?

I’m going to when I get round to testing it. Probably later today. :slight_smile:

Hi again. How would I make it like in the second image where it goes up on an arch and comes back down? I gave the projectile motion a shot but I couldn’t figure it out. Thanks again! :slight_smile:

You basically just use the quadratic formula if you want a straight forward approach like that. I prepared a desmos model for you

1 Like

I think for force, you could simply use Part.Velocity += Vector3.new(x,y,z)
It’ll accelerate the part and any other parts welded to it in the direction of the vector. (Assuming its looping)