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.
UIS.InputBegan:Connect(function(Input) if Input.KeyCode == Enum.KeyCode.S then -- this is moving backward when you click S if Toggle == false then return end HumaoidRP.Anchored = false if HumaoidRP:FindFirstChildOfClass("BodyVelocity") then HumaoidRP:FindFirstChildOfClass("BodyVelocity"):Destroy() end local Back = Instance.new("BodyVelocity",HumaoidRP) Back.Name = "BackMovement" Back.MaxForce = Vector3.new(math.huge,math.huge,math.huge) local Gyro = Instance.new("BodyGyro",HumaoidRP) Gyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge) Gyro.D = 100 Gyro.P = 10000 while Toggle == true do Back.Velocity = Mouse.Hit.lookVector*-30 --I found that if the number is a negative, it goes backwards, if it's positive, it moves forward Gyro.CFrame = Mouse.Hit wait() end end end) UIS.InputEnded:Connect(function(Input) if Input.KeyCode == Enum.KeyCode.S then if Toggle == false then return end if HumaoidRP:FindFirstChild("BackMovement") then HumaoidRP.BackMovement:Destroy() HumaoidRP.Anchored = true if HumaoidRP:FindFirstChildOfClass("BodyGyro") then HumaoidRP:FindFirstChildOfClass("BodyGyro"):Destroy() end end end end)
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?
So, how a body velocity works is it moves the character by how much you told it to, so here's how to move the player to the right, Change this line:
Back.Velocity = Mouse.Hit.lookVector*Vector3.new(30,0,0)
To the right:
Back.Velocity = Mouse.Hit.lookVector*Vector3.new(-30,0,0)
Hope it helps!