How to make a player move left/right for a keybind script?
Hello, I know the question was a bit wonky but I have a script here where, if you double jump, you will fly until you double jump again. It can only go forward(keybind W) and backward(keybind S)
Here is the script of the movement.
01 | UIS.InputBegan:Connect( function (Input) |
02 | if Input.KeyCode = = Enum.KeyCode.S then |
03 | if Toggle = = false then return end |
04 | HumaoidRP.Anchored = false |
05 | if HumaoidRP:FindFirstChildOfClass( "BodyVelocity" ) then |
06 | HumaoidRP:FindFirstChildOfClass( "BodyVelocity" ):Destroy() |
08 | local Back = Instance.new( "BodyVelocity" ,HumaoidRP) |
09 | Back.Name = "BackMovement" |
10 | Back.MaxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
11 | local Gyro = Instance.new( "BodyGyro" ,HumaoidRP) |
12 | Gyro.MaxTorque = Vector 3. new( math.huge , math.huge , math.huge ) |
15 | while Toggle = = true do |
16 | Back.Velocity = Mouse.Hit.lookVector*- 30 |
17 | Gyro.CFrame = Mouse.Hit |
22 | UIS.InputEnded:Connect( function (Input) |
23 | if Input.KeyCode = = Enum.KeyCode.S then |
24 | if Toggle = = false then return end |
25 | if HumaoidRP:FindFirstChild( "BackMovement" ) then |
26 | HumaoidRP.BackMovement:Destroy() |
27 | HumaoidRP.Anchored = true |
28 | if HumaoidRP:FindFirstChildOfClass( "BodyGyro" ) then |
29 | HumaoidRP:FindFirstChildOfClass( "BodyGyro" ):Destroy() |
My problem is, how can I make it go right/left? I know I need to change the .Velocity = Mouse.Hit.lookVector*-30, but not sure how. I know that it's all math but I'm very unsure. Does anyone know how to make the movement go right/left?