Hi, I got a script from my friend that makes a player fly. But only fly infront (with W) and back (with S). But not on left or right. Here is a part (more important part) of the script:
UIS.InputBegan:Connect(function(Input) if Input.KeyCode == Enum.KeyCode.W then if Toggle == false then return end PlayAnim:Play() HumaoidRP.Anchored = false if HumaoidRP:FindFirstChildOfClass("BodyVelocity") then HumaoidRP:FindFirstChildOfClass("BodyVelocity"):Destroy() end local Forward = Instance.new("BodyVelocity",HumaoidRP) Forward.Name = "ForwardMovement" Forward.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 Forward.Velocity = Mouse.Hit.lookVector*150 --HERE Gyro.CFrame = Mouse.Hit wait() end end end)
There where --HERE
is, is the lookVector.
If we look at this here:
---------FRONT--
LEFT--player--RIGHT
---------BACK---
FRONT is the position of lookVector. There would make logic if there is also something for LEFT and RIGHT?
I tryed to get left/right with CFrame. But CFrame is global value(it is always on the same orientation, not like a part or a player).
Now my Question: Is there a way to get left/right vector?
Along with LookVector, there are two other properties of CFrame called RightVector and UpVector. To find the left vector, simply multiply the RightVector by -1, and the same to get the bottom vector from UpVector.