Why is my drone not falling/going under 0?

I’ve been working on my drone for quite awhile. @T0ny helped me and now the drone is going up but not down. The VectorForce is set to 0 yet the drone isn’t going down. And I also noticed that if I try to subtract the VectorForce and make the Y axis go under 0 it’s not working.

Module Script:

local Drone = {}
Drone_mt = {__index = Drone}

Drone.new = function(model, camera)
	local self = {}
	self.Speed = 20
	self.Model = model
	self.VectorForce = model.VectorForce
	self.Camera = camera
	self.Direction = Vector3.new(0,0,0)
	self.Rotation = 0

	return setmetatable(self, Drone_mt)
end
function Drone:Up(actionName, inputState, inputObject)
	if inputState == Enum.UserInputState.Begin then
		self.Direction = self.Direction + Vector3.new(0, 1, 0)
	else
		self.Direction = self.Direction - Vector3.new(0, 1, 0)
	end
end

function Drone:Down(actionName, inputState, inputObject)
	if inputState == Enum.UserInputState.Begin then
		self.Direction = self.Direction - Vector3.new(0, 1, 0)
	else
		self.Direction = self.Direction + Vector3.new(0, 1, 0)
	end
end

function Drone:Update(actionName, inputState, inputObject)
	if not self.VectorForce then return end
	
	local X, Y, Z = math.clamp(self.Direction.X, 0, 1), math.clamp(self.Direction.Y, 0, 1), math.clamp(self.Direction.Z, 0, 1)
	local Direction = Vector3.new(X, Y, Z)
	self.VectorForce.Force = Direction * (self.Model.Mass * self.Speed)
end

return Drone

Local Script:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")

local Module = require(game.ReplicatedStorage.Drone)
local LocalPlayer = Players.LocalPlayer
local character = LocalPlayer.Character.HumanoidRootPart
local newDrone = Module.new(character)


local function handleUp(actionName, inputState, inputObject)
	newDrone:Up(actionName, inputState, inputObject)
end

local function handleDown(actionName, inputState, inputObject)
	newDrone:Down(actionName, inputState, inputObject)
end

ContextActionService:BindAction("Up", handleUp, true, Enum.KeyCode.E)
ContextActionService:BindAction("Down", handleDown, true, Enum.KeyCode.Q)

RunService.Stepped:Connect(function(step)
	newDrone:Update(step)
end)

The problem is the drone isn’t going down when the vector force is 0.

Thanks!

I would appreciate every reply, I am stuck with this.

Have you tried using other types of body movers? By not going down, do you mean that it keeps going up?

No, it’s literally getting stuck mid-air.

Try printing out direction after every action, see if it keeps increasing and not decreasing. I feel like that using else on inputstate.began will not work because when the function goes off, it will always be began and not else? I never use contextactionservice, but does it fire twice? one when button down and once when up?

Well now I changed the script and here’s the result:

local Drone = {}

Drone_mt = {__index = Drone}

Drone.new = function(model, camera)

local self = {}

self.Speed = 20

self.Model = model

self.VectorForce = model.VectorForce

self.Camera = camera

self.Direction = Vector3.new(0,0,0)

self.Rotation = 0

return setmetatable(self, Drone_mt)

end

function Drone:Up(actionName, inputState, inputObject)

if inputState ~= Enum.UserInputState.Begin then return end

self.Direction = self.Direction + Vector3.new(0, 1, 0)

end

function Drone:Down(actionName, inputState, inputObject)

if inputState ~= Enum.UserInputState.Begin then return end

self.Direction = self.Direction - Vector3.new(0, 1, 0)

end

function Drone:Update(actionName, inputState, inputObject)

if not self.VectorForce then return end

local X, Y, Z = math.clamp(self.Direction.X, -1, 1), math.clamp(self.Direction.Y, -1, 1), math.clamp(self.Direction.Z, -1, 1)

local Direction = Vector3.new(X, Y, Z)

self.VectorForce.Force = Direction * (self.Model.Mass * self.Speed)

end

return Drone

Well apparently this fixed the problem but when the direction is like in 30 you need to press a lot of Q in order to make it go minus. How will I make that?

You could check if Direction.Y >= 1 and if so then return and vice versa for the opposite direction.

Does that mean the direction can’t pass 1?

Yeah, it means that if the direction.Y is 1, then it wont add more to it.

Well then it can’t go up too much, am I correct? And will I also reset it to 0 whenever it tries to pass 1 so the player can still go up?