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!