I have seen how to get the mobile thumbstick on the forum but they talk about how to specifically get the direction of where they move it to like up, down, right, and left. I know that you use :
local GetMoveVector = require(player:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule")):GetMoveVector()
But How would I know if they moved it up or the other directions?
maybe compare the vector of the look vector of the camera to the vector the direction of the thumb stick. Another is to get the location where the thumbstick is (i am thinking like a table?) and compare it to see if it is going up or down
Got it to work but somehow when I stop moving you still keep flying the same direction. It won’t even print ended.
local Tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local HumanRootPart = character:WaitForChild("HumanoidRootPart")
local cam = game.Workspace.CurrentCamera
local Debris = game:GetService("Debris")
local UserInputS = game:GetService("UserInputService")
local ContextActionS = game:GetService("ContextActionService")
local pressed = false
local BodyVel
local BodyGyro
local Force = 2500000
local RunService = game:GetService("RunService")
local debounce = false
local RemoteEvent = Tool:WaitForChild("RemoteEvent")
local camConnW
local camConnA
local camConnS
local camConnD
local RunService = game:GetService("RunService")
local GetMoveVector = require(player:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule"))
local WPressed = "WFoward"
local function foward(Vector)
if Vector.z >= -1 and Vector.z < 0 then
camConnW = cam:GetPropertyChangedSignal("CFrame"):Connect(function()
if Vector.z >= -1 and Vector.z < 0 then
BodyVel.Velocity = cam.CFrame.LookVector * 65
end
end)
print("began")
else
if camConnW then
camConnW:Disconnect()
camConnW = nil
end
BodyVel.Velocity = Vector3.new(0,0,0)
print("ended")
end
end
local APressed = "ALeft"
local function left(Vector)
if Vector.x >= -1 and Vector.x < 0 then
camConnA = cam:GetPropertyChangedSignal("CFrame"):Connect(function()
if Vector.x >= -1 and Vector.x < 0 then
BodyVel.Velocity = cam.CFrame.RightVector * -65
end
end)
print("began")
else
if camConnA then
camConnA:Disconnect()
camConnA = nil
end
BodyVel.Velocity = Vector3.new(0,0,0)
end
end
local SPressed = "SBack"
local function back(Vector)
if Vector.z > 0 then
camConnS = cam:GetPropertyChangedSignal("CFrame"):Connect(function()
if Vector.z > 0 then
BodyVel.Velocity = cam.CFrame.LookVector * -65
end
end)
print("began")
else
if camConnS then
camConnS:Disconnect()
camConnS = nil
end
BodyVel.Velocity = Vector3.new(0,0,0)
end
end
local DPressed = "Dright"
local function right(Vector)
if Vector.x > 0 then
camConnD = cam:GetPropertyChangedSignal("CFrame"):Connect(function()
if Vector.x > 0 then
BodyVel.Velocity = cam.CFrame.RightVector * 65
end
end)
print("began")
else
if camConnD then
camConnD:Disconnect()
camConnD = nil
end
BodyVel.Velocity = Vector3.new(0,0,0)
end
end
Tool.Activated:Connect(function()
if not pressed then
pressed = true
BodyVel = Instance.new("BodyVelocity")
BodyGyro = Instance.new("BodyGyro")
BodyGyro.Parent = HumanRootPart
BodyGyro.MaxTorque = Vector3.new(1, 1, 1)*10^6;
BodyGyro.P = 10^6;
BodyVel.Parent = HumanRootPart
BodyVel.P = 10^5;
BodyVel.MaxForce = Vector3.new(Force,Force,Force)
BodyVel.Velocity = Vector3.new(0,0,0)
RunService.Heartbeat:Connect(function()
if not debounce then
debounce = true
if BodyGyro and BodyGyro.Parent then
BodyGyro.CFrame = cam.CFrame
end
wait(0.01)
debounce = false
end
end)
while wait(0.1)do
local Vector = GetMoveVector:GetMoveVector()
if Vector == Vector3.new(0, 0, 0) then
BodyVel.Velocity = Vector3.new(0,0,0)
--print("Idle")
if camConnW and camConnA and camConnS and camConnD then
camConnW:Disconnect()
camConnA:Disconnect()
camConnS:Disconnect()
camConnD:Disconnect()
end
elseif Vector.z >= -1 and Vector.z < 0 then
foward(Vector)
elseif Vector.z > 0 then
back(Vector)
elseif Vector.x >= -1 and Vector.x < 0 then
left(Vector)
elseif Vector.x > 0 then
right(Vector)
end
end
elseif pressed then
pressed = false
BodyGyro:Destroy()
BodyVel:Destroy()
if camConnW then
camConnW:Disconnect()
camConnW = nil
end
if camConnA then
camConnA:Disconnect()
camConnA = nil
end
if camConnS then
camConnS:Disconnect()
camConnS = nil
end
if camConnD then
camConnD:Disconnect()
camConnD = nil
end
end
end)