Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I need help removing the falling animation on my r15 flying script?


repeat wait() until game.Players.LocalPlayer.Character
 
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local Torso = char:WaitForChild("LowerTorso")
local Mouse = plr:GetMouse()
local toggle = false
 
Mouse.KeyDown:Connect(function(key)
    if key == "f" then
        if toggle == false then
            toggle = true
            local BV = Instance.new("BodyVelocity",Torso)
            BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
            while toggle == true do
                BV.Velocity = Mouse.Hit.lookVector*100
                wait()
            end
        end
        if toggle == true then
            toggle = false
            Torso:FindFirstChildOfClass("BodyVelocity"):remove()
            local tracks = hum:GetPlayingAnimationTracks()
            for i, stoptracks in pairs(tracks) do
                stoptracks:Stop()
            end
        end
    end
end)

4 comments

0

Please don't use KeyDown, it was deprecated. Please be a bit more descriptive about your intentions and whats not working, so we can be better-equipped to help you.

0

(Ignore my Claim for 200r+, accidental)

0

@Feahren, i got you, lol, anyway, the function :remove() is also deprecated, in favor of :Destroy()

0

If you're going to detect key input, use UserInputService, not KeyDown.

1 answer

repeat wait() until game.Players.LocalPlayer.Character

local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local Torso = char:WaitForChild("LowerTorso")
local Mouse = plr:GetMouse()
local toggle = false

Mouse.KeyDown:Connect(function(key)
    if key == "f" then
        if toggle == false then
            toggle = true
            local BV = Instance.new("BodyVelocity",Torso)
            BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
char.Animate.fall.FallAnim.AnimationId = "0"

            while toggle == true do
                BV.Velocity = Mouse.Hit.lookVector*100
                wait()
            end
        end
        if toggle == true then
            toggle = false
            Torso:FindFirstChildOfClass("BodyVelocity"):remove()
char.Animate.fall.FallAnim.AnimationId = "http://www.roblox.com/asset/?id=507767968"

            local tracks = hum:GetPlayingAnimationTracks()
            for i, stoptracks in pairs(tracks) do
                stoptracks:Stop()
            end
        end
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.