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

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

Asked by 5 years ago

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)
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. Ziffixture 6913 — 5y
0
(Ignore my Claim for 200r+, accidental) Ziffixture 6913 — 5y
0
@Feahren, i got you, lol, anyway, the function :remove() is also deprecated, in favor of :Destroy() SerpentineKing 3885 — 5y
0
If you're going to detect key input, use UserInputService, not KeyDown. DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
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)
Ad

Answer this question