Well Theres two problems with this script when you tap double space, you float with a bodyvelocity then when you press w you move forward but when you release you go backward when your supposed to stop moving Help???
Second Problem is when you press w your torso is supposed to follow the position of your mouse cursor but It doesn't do it when your holding w.. it only does it once. Help?
SCRIPT__A bit long.. I know
Torso = script.Parent.Parent.Character.Torso
wtap = false
mouse = script.Parent.Parent:GetMouse()
Flying = false
p = game.Players.LocalPlayer
c = p.Character
Forward = false
mouse.KeyDown:connect(function(key)
key = key:lower()
if key==string.char(32) then if wtap == false then
if Flying == false then
wtap = true
wait(0.1)
wtap = false
Flying = true
print('Flight')
local flygyro = Instance.new("BodyVelocity",c.Torso)
flygyro.maxForce = Vector3.new(math.huge,math.huge,math.huge)
flygyro.Name = "FlyVelo"
flygyro.Velocity = Vector3.new(0,0,0)
wtap = false
local doublewtap = true end
end
end
end)
function forward(key)
key:lower()
if key == "w" then
if Flying == true then
Forward = true
local pos = mouse.Hit.p
local Gyro = Instance.new("BodyGyro")
local Position = Instance.new("BodyPosition")
Gyro.Parent = Torso
Position.Parent = Torso
print('Foward')
while Forward == true do
wait()
Torso.FlyVelo.velocity = Torso.CFrame.lookVector * -30
Gyro.D = 225
Gyro.cframe = Torso.CFrame
Gyro.Name = "Gyro"
Gyro.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
Position.position = Torso.Position
Position.maxForce = Vector3.new(math.huge, math.huge, math.huge)
Position.Name = "Pos"
Gyro.cframe = CFrame.new(Torso.Position, pos)
Torso.CFrame = CFrame.new(Torso.Position, pos)
end
end
end
end
function stopforward(key)
if key == "w" then
if Forward == true and Flying == true then
print('Not flying forward')
Forward = false
Torso.Gyro:Destroy()
Torso.Pos:Destroy()
Torso.FlyVelo.velocity = Torso.CFrame.lookVector*0
end
end
end
mouse.KeyDown:connect(forward)
mouse.KeyUp:connect(stopforward)
