Why I cant move while flying I just stuck and cant move foward or backward ,can you help me and thanks
this is the local script :
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
wait(1)
local IsFlying = false
local Torso = char.UpperTorso
local last = tick()
local function flight()
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Parent = Torso
bv.Name = "FlightVelocity"
bv.Velocity = Vector3.new(0,0,0)
end
UIS.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.Space then
if (tick()-last) < 0.5 then
IsFlying = not IsFlying
if IsFlying then
flight()
else
local bv = Torso:FindFirstChild("FlightVelocity")
if bv then bv:Destroy() end
end
elseif IsFlying then
local bv = Torso:FindFirstChild("FlightVelocity")
if bv then bv.Velocity = Vector3.new(0,16,0) end
end
last = tick()
end
if input.KeyCode == Enum.KeyCode.LeftControl then
local bv = Torso:FindFirstChild("FlightVelocity")
if bv then bv.Velocity = Vector3.new(0,-16,0) end
end
end)
UIS.InputEnded:Connect(function(input,gpe)
if input.KeyCode == Enum.KeyCode.Space or input.KeyCode == Enum.KeyCode.LeftControl then
local bv = Torso:FindFirstChild("FlightVelocity")
if bv then bv.Velocity = Vector3.new(0,0,0) end
end
end)