It should fly when you press 2 times space and stop with 1 time, but it does not work.
local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse() function GetMassRecursive(p) local mass = 0 for i,v in pairs(p:GetChildren())do if #v:GetChildren() > 0 then mass = mass + GetMassRecursive(v) end if v:IsA("Part") then print(v.Name) mass = mass + v:GetMass() end end return mass end local wDown = false local sDown = false local isFlying = false local speed = 10 local U = game:GetService("UserInputService") Player = game:GetService("Players").LocalPlayer local running = false local s = "" local on = game.ReplicatedStorage.Events:WaitForChild('FlyOn') U.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.Space then s = s.."w" print('UnFlying') local tool1 = player.Character.UpperTorso local tools = {"Anti-Grav", "FlyingVelocity"} for i,v in pairs(tools) do local tool = tool1:FindFirstChild(v) if tool then tool:Destroy() player.Character.Humanoid.PlatformStand = false isFlying = false end end delay(0.2,function () if s ~= "ww" then s = "" end end) if s == "ww" then print('flying') if isFlying then speed = 0 wait() speed = 10 local f = Instance.new("BodyForce") f.Name = "Anti-Grav" f.Force = Vector3.new(0,196.2,0) * (GetMassRecursive(player.Character)) f.Parent = player.Character.UpperTorso local v = Instance.new("BodyVelocity") v.Velocity = (mouse.Hit.p - player.Character.UpperTorso.Position).unit * 10 v.P = 100 v.MaxForce = Vector3.new(math.huge,math.huge,math.huge) v.Name = "FlyingVelocity" v.Parent = player.Character.UpperTorso player.Character.Humanoid.PlatformStand = true isFlying = true end end if key.KeyCode == Enum.KeyCode.W then wDown = true end if key.KeyCode == Enum.KeyCode.S then sDown = true end end end) U.InputBegan:connect(function(key) if key.KeyCode == Enum.KeyCode.W then wDown = false end if key.KeyCode == Enum.KeyCode.S then sDown = false end end) local MAX_SPEED = 500 local MIN_SPEED = 0 spawn(function() while player.Character.Humanoid.Health > 0 do if isFlying then local r = 1+(speed/500) player.Character:SetPrimaryPartCFrame(CFrame.new(player.Character.PrimaryPart.Position,mouse.Hit.p)*CFrame.Angles(math.pi/r,math.pi,math.pi)) player.Character.UpperTorso.FlyingVelocity.Velocity = (mouse.Hit.p - player.Character.UpperTorso.Position).unit * speed if wDown then speed = speed + 5 if speed > MAX_SPEED then speed = MAX_SPEED end elseif sDown then speed = speed - 5 if speed < MIN_SPEED then speed = MIN_SPEED end end end game:GetService("RunService").RenderStepped:wait() end end)