Hi I Testing Make A Fly Script My Fly Script Not Stopping Help Please
Code :
local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local flying = false
player.CharacterAdded:Connect(function(chr)
local humanoid = chr:WaitForChild("Humanoid")
local humanoidrootpart = chr:WaitForChild("HumanoidRootPart")
local uppertorso = chr:WaitForChild("UpperTorso")
local bodyvelocity = Instance.new("BodyVelocity",uppertorso)
bodyvelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyvelocity.Velocity = Vector3.new(0,1,0)
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.W then
flying = true
print("pressing w")
while flying == true do wait()
bodyvelocity.Velocity = humanoidrootpart.CFrame.LookVector * 100
end
end
end)
UIS.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.W then
flying = false
print("press w ended")
end
end)
end)