This a flying script that's supposed to rotate the body when the player moves their camera. It works but when the player has a 2-handed weapon equipped and they press V to start flying, they can't move their body up/down when moving their camera. Can anyone explain why this is happening?

Here is a part of the script

game.Players.LocalPlayer.Character:findFirstChild("Torso") 
game.Players.LocalPlayer.Character:findFirstChild("Humanoid") 
local mouse = game.Players.LocalPlayer:GetMouse() 
repeat wait() until mouse
local plr = game.Players.LocalPlayer 
local root = plr.Character:WaitForChild("HumanoidRootPart") 
local flying = false 
local ctrl = {f = 0, b = 0, l = 0, r = 0} 
local lastctrl = {f = 0, b = 0, l = 0, r = 0}  
local speed = 60
 
function Fly()
	local bg = Instance.new("BodyGyro", root) 
	bg.P = 9e4 
	bg.maxTorque = Vector3.new(9e3, 9e3, 9e3) 
	bg.cframe = root.CFrame 
	local bv = Instance.new("BodyVelocity", root) 
	bv.velocity = Vector3.new(0,0,0) 
	bv.maxForce = Vector3.new(9e9, 9e9, 9e9) 
		repeat wait() 
		plr.Character.Humanoid.PlatformStand = true 
			if (ctrl.l + ctrl.r) ~= 0 or (ctrl.f + ctrl.b) ~= 0 then 
				bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (ctrl.f+ctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(ctrl.l+ctrl.r,(ctrl.f+ctrl.b)*0,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*60
				lastctrl = {f = ctrl.f, b = ctrl.b, l = ctrl.l, r = ctrl.r} 
			elseif (ctrl.l + ctrl.r) == 0 and (ctrl.f + ctrl.b) == 0 and speed ~= 0 then 
				bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (lastctrl.f+lastctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(lastctrl.l+lastctrl.r,(lastctrl.f+lastctrl.b)*0,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*0 
			else 
				bv.velocity = Vector3.new(0,0,0) 
			end 
		bg.cframe = game.Workspace.CurrentCamera.CoordinateFrame 
		until not flying 
			ctrl = {f = 0, b = 0, l = 0, r = 0} 
			lastctrl = {f = 0, b = 0, l = 0, r = 0} 
			speed = 0 
			bg:Destroy() 
			bv:Destroy() 
			plr.Character.Humanoid.PlatformStand = false 
		end

2 comments

0

This script was coded by Kohltastrophe. >->

0

Well that's not helpful...