Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make my character fly in the opposite direction it is facing?

Asked by 3 years ago
Edited 3 years ago

Here's my code:

local function CheckInput(Input, GameProcessed)
    if GameProcessed then return end
    if Input.KeyCode == Enum.KeyCode.F then
        --FireFlight   
        if flying == false then
            flying = true
            game.ReplicatedStorage.Fire.Flight:FireServer("FlyingIsTrue")
            local bv = Instance.new("BodyVelocity")
            bv.Parent = hroot
            bv.MaxForce = Vector3.new(99999, 99999, 99999)
            bv.Velocity = Vector3.new(0, 0, 0)
            while flying == true do
                wait()
                animtrack:Play()
                local Velocity = hum.MoveDirection* Vector3.new(50, 0, 50) + game.Workspace.CurrentCamera.CoordinateFrame.lookVector * Vector3.new(0, 40, 0)
                bv.Velocity = Velocity
            end
        end
        if flying == true then
            flying = false
            wait()
            game.ReplicatedStorage.Fire.Flight:FireServer("FlyingIsFalse")
            animtrack:Stop()
            local ExistingForce = hroot:FindFirstChildOfClass("BodyVelocity")
            ExistingForce:Destroy()
        end
    end
end

UIS.InputBegan:Connect(CheckInput)

It currently only flies in the direction you are moving with WASD, and in the vertical direction that your camera is facing at.

Example

I would like the character to be able to move upwards when the camera is facing down and the player is holding the S key.

Thank you in advance. <3

Answer this question