Hello, im trying to make ODM gear in AOT kind of like this: https://twitter.com/returnedbydeath/status/1612206224140910592 3
However, im having trouble in making the player go/tilt to the left/right when pressing A or D, here is my code:
-- Variables
local boostSpeed = 100
local player = game.Players.LocalPlayer
local character = workspace:WaitForChild(player.Name)
local HRP = character.HumanoidRootPart
local CurrentERope = nil
local EConnections = {}
local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")
local moveSpeed = 200
local IsTiltingA = false
local IsTiltingD = false
--Fired when pressing/unpressing A or D
local function movePlayer(direction)
if CurrentERope then
local movementDirection = direction * moveSpeed
local velocity = Vector3.new(movementDirection.X, 0, movementDirection.Z)
CurrentERope.Velocity = CurrentERope.Velocity+velocity
end
end
local function SubtractVelocity(direction)
if CurrentERope then
local movementDirection = direction * moveSpeed
local velocity = Vector3.new(movementDirection.X, 0, movementDirection.Z)
CurrentERope.Velocity = CurrentERope.Velocity-velocity
end
end
--Fired when pressing E
local mPos = player:GetMouse().Hit.Position
local bv = Instance.new("BodyVelocity", HRP)
CurrentERope = bv
bv.MaxForce = Vector3.one * math.huge
bv.P = math.huge
bv.velocity = (mPos - HRP.Position).Unit * boostSpeed
-- Updating BV.
local conn = RS.Heartbeat:Connect(function(deltaTime)
bv.velocity = (mPos - HRP.Position).Unit * boostSpeed
if IsTiltingA then
local movementDirection = Vector3.new(-1, 0, 0) * moveSpeed
local velocity = Vector3.new(movementDirection.X, 0, movementDirection.Z)
CurrentERope.Velocity = CurrentERope.Velocity+velocity
end
if IsTiltingD then
local movementDirection = Vector3.new(1, 0, 0) * moveSpeed
local velocity = Vector3.new(movementDirection.X, 0, movementDirection.Z)
CurrentERope.Velocity = CurrentERope.Velocity+velocity
end
print(bv.Velocity)
end)
table.insert(EConnections, conn)