Jetpack Mechanics

I’m trying to design a jetpack system with the mechanics as shown in the following video:

So when the player presses a mouse button, he changes his speed and his direction.
I’ve made a script trying to replicate that mechanic:

local VF = Instance.new("VectorForce")
local speed = 100
print(speed)
VF.Parent = script.Parent:WaitForChild("HumanoidRootPart")
VF.Attachment0 = VF.Parent:WaitForChild("RootRigAttachment")
game:GetService("RunService").RenderStepped:Connect(function()
	if game:GetService("UserInputService"):IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then
		if speed < 200 then
			print(speed)
			speed = speed * 1.01
			VF.Force = game.Workspace.CurrentCamera.CFrame.LookVector * speed
		else
			speed = 200
		end
		VF.Force = game.Workspace.CurrentCamera.CFrame.LookVector * speed
	elseif game:GetService("UserInputService"):IsMouseButtonPressed(Enum.UserInputType.MouseButton2) then
		if speed > 100 then
			print(speed)
			speed = speed / 1.01
		else
			speed = 100
		end
		VF.Force = game.Workspace.CurrentCamera.CFrame.LookVector * speed
	end
end)

Although when the gravity is set to zero and the player is flying, the only direction player can move using this script is up and down.
How do I fix that?
Thanks.

I believe its your use of LookVector, read this thread to see if it might help to change to just cframe:

1 Like

After reading this post, I still was unable to formulate a solution to my problem.

Have you tried to set the gravity to something negligible, like 0.01?

Indeed, although it still does not work.

this video should help

1 Like

@5uphi does this also work with mobile?

looking further into the video, he does indeed use context action service to bind the action

2 Likes

Excellent tutorial and resource @5uphi thank you for that.

No problem i’m happy that you liked it

1 Like