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

How Do I Make My Fly Script, Go Faster With SHIFT, and the run script doesn't help?

Asked by 6 years ago
down = false
velocity = Instance.new("BodyVelocity")
velocity.maxForce = Vector3.new(100000, 100000, 100000)

gyro = Instance.new("BodyGyro")
gyro.maxTorque = Vector3.new(100000, 100000, 100000)

effect = script.Parent.Sparkles

function onButton1Down(mouse)
    down = true
    velocity.Parent = game.Players.LocalPlayer.Character.UpperTorso
    velocity.velocity = workspace.CurrentCamera.CoordinateFrame.lookVector * 30
    gyro.Parent = game.Players.LocalPlayer.Character.UpperTorso
    effect.Parent = game.Players.LocalPlayer.Character.UpperTorso
    while down do
        if not down then break end
        velocity.velocity = workspace.CurrentCamera.CoordinateFrame.lookVector * 30
        local refpos = gyro.Parent.Position + (gyro.Parent.Position - workspace.CurrentCamera.CoordinateFrame.p).unit * 5
        gyro.cframe = CFrame.new(gyro.Parent.Position, Vector3.new(refpos.x, gyro.Parent.Position.y, refpos.z))
        wait(0.1)
    end
end

function onButton1Up(mouse)
    velocity.Parent = nil
    gyro.Parent = nil
    effect.Parent = script.Parent
    down = false
end

function onSelected(mouse)
    mouse.Button1Down:connect(function() onButton1Down(mouse) end)
    mouse.Button1Up:connect(function() onButton1Up(mouse) end)
end

script.Parent.Selected:connect(onSelected)
script.Parent.Deselected:connect(onButton1Up)

There is my script, and it works fine and its a tool for my game already. It works I just need help with editing it so its a Faster flying when I use SHIFT.

1 answer

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
6 years ago

UserInputService is your best friend.

game:GetService('UserInputService').InputBegan:connect(function(kek, process)
    kek = kek.KeyCode
    if not process then
        if kek == Enum.KeyCode.LeftShift then
            FasterFly = true
        end
    end
end)

game:GetService('UserInputService').InputEnded:connect(function(kek, process)
    kek = kek.KeyCode
    if not process then
        if kek == Enum.KeyCode.LeftShift then
            FasterFly = false
        end
    end
end)


Ad

Answer this question