Hi!
I just wanted to show the flying script ive been working on!
Im currently making an avatar game and the script is for the airbenders.
Im very proud of the scriot as im not a pro scripter (yet) but maybe if you see a potential bug you could mention it?
repeat wait() until game.Players.LocalPlayer.Character
local remote = game.ReplicatedStorage.GiveGlider
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Char = plr.Character
local Hum = Char:WaitForChild("Humanoid")
local torso = Char:WaitForChild("LowerTorso")
local Root = Char:WaitForChild("HumanoidRootPart")
local mouse = plr:GetMouse()
local IsFlying = false
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
if IsFlying == false then
IsFlying = true
if Char:FindFirstChild("Glider") then
Char:FindFirstChild("Glider"):Destroy()
end
if not Char:FindFirstChild("GliderOn") then
remote:FireServer(Hum)
end
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://5839619304" --GliderAnimation
local PlayAnim = Hum:LoadAnimation(Anim)
PlayAnim:Play()
local bodyvelocity = Instance.new("BodyVelocity", torso)
bodyvelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local bodygyro = Instance.new("BodyGyro", Root)
while IsFlying == true do
bodyvelocity.Velocity = mouse.Hit.lookVector*100
Char.HumanoidRootPart.CFrame = CFrame.new(Char.HumanoidRootPart.CFrame.Position, Vector3.new(mouse.Hit.Position.X, Char.HumanoidRootPart.CFrame.Position.Y, mouse.Hit.Position.Z))
wait()
end
Hum.Touched:Connect(function(part)
IsFlying = false
if torso:FindFirstChildOfClass("BodyVelocity") then
torso:FindFirstChildOfClass("BodyVelocity"):Destroy()
local AnimationTracks = Hum:GetPlayingAnimationTracks()
for i, stoptracks in pairs(AnimationTracks) do
stoptracks:Stop()
end
if Char:FindFirstChild("GliderOn") then
Char:FindFirstChild("GliderOn"):Destroy()
end
if not Char:FindFirstChild("Glider") then
game.ReplicatedStorage.GiveGliderOff:FireServer(plr)
end
end
end)
end
if IsFlying == true then
IsFlying = false
if torso:FindFirstChildOfClass("BodyVelocity") then
torso:FindFirstChildOfClass("BodyVelocity"):Destroy()
local AnimationTracks = Hum:GetPlayingAnimationTracks()
for i, stoptracks in pairs(AnimationTracks) do
stoptracks:Stop()
end
if Char:FindFirstChild("GliderOn") then
Char:FindFirstChild("GliderOn"):Destroy()
end
if not Char:FindFirstChild("Glider") then
game.ReplicatedStorage.GiveGliderOff:FireServer(plr)
end
end
end
end
end)