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.