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)
COMMUNITY QUESTION
I need help removing the falling animation on my r15 flying script?
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.

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