local A=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local p=A:WaitForChild("\077\111\100\117\108\101\115")local f=require(p.src.utils.Logger)local R=require(p.M)local u=game:GetService("\082\117\110\083\101\114\118\105\099\101")local K=game.Workspace.CurrentCamera local d=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local i={}i.__index=i function i.create(p,A)local f=Instance.new("\066\111\100\121\080\111\115\105\116\105\111\110",A)f.MaxForce=Vector3.new()f.D=10 f.P=10000 local R=Instance.new("\066\111\100\121\071\121\114\111",A)R.MaxTorque=Vector3.new()R.D=10 local u={humanoid=A,flying=false,floating=true;speed=.5;BodyPosition=f,BodyGyro=R}setmetatable(u,i)return u end function i.initInput(A)local p={Enum.UserInputType.Touch;Enum.UserInputType.MouseButton1,Enum.UserInputType.MouseButton2}d.InputBegan:Connect(function(f)if not f then return end if R.include(p,f.UserInputType)then A:endFloating()end end)d.InputEnded:Connect(function(f)if not f then return end if R.include(p,f.UserInputType)then A:startFloating()end end)end function i.startFlying(A)A.flying=true A.BodyPosition.MaxForce=Vector3.new(400000,400000,400000)A.BodyGyro.MaxTorque=Vector3.new(400000,400000,400000)while A.flying do local p=K.CFrame.p if A.floating then else A.BodyPosition.Position=A.humanoid.Position+(A.humanoid.Position-p).unit*A.speed end A.BodyGyro.CFrame=CFrame.new(p,A.humanoid.Position)u.RenderStepped:wait()end end function i.endFlying(A)A.BodyPosition.MaxForce=Vector3.new()A.BodyGyro.MaxTorque=Vector3.new()A.flying=false end function i.startFloating(A)A.floating=true end function i.endFloating(A)A.floating=false end return i
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Modules = ReplicatedStorage:WaitForChild('Modules')
local logger = require(Modules.src.utils.Logger)
local M = require(Modules.M)
local RunService = game:GetService('RunService')
local camera = game.Workspace.CurrentCamera
local UserInputService = game:GetService('UserInputService')

local FlyScript = {}

FlyScript.__index = FlyScript

function FlyScript:create(humanoid)
	local BodyPosition = Instance.new('BodyPosition', humanoid)
	BodyPosition.MaxForce = Vector3.new()
	BodyPosition.D = 10
	BodyPosition.P = 10000

	local BodyGyro = Instance.new('BodyGyro', humanoid)
	BodyGyro.MaxTorque = Vector3.new()
	BodyGyro.D = 10

	local this = {
		humanoid = humanoid,
		flying = false,
		floating = true,
		speed = 0.5,
		BodyPosition = BodyPosition,
		BodyGyro = BodyGyro,
	}

	setmetatable(this, FlyScript)
	return this
end

function FlyScript:initInput()
	local inputTypes = { Enum.UserInputType.Touch, Enum.UserInputType.MouseButton1, Enum.UserInputType.MouseButton2 }

	UserInputService.InputBegan:Connect(function(inputObject)
		if not inputObject then return end

		if M.include(inputTypes, inputObject.UserInputType) then
			self:endFloating()
		end
	end)

	UserInputService.InputEnded:Connect(function(inputObject)
		if not inputObject then return end

		if M.include(inputTypes, inputObject.UserInputType) then
			self:startFloating()
		end
	end)
end

function FlyScript:startFlying()
	self.flying = true
	self.BodyPosition.MaxForce = Vector3.new(400000, 400000, 400000)
	self.BodyGyro.MaxTorque = Vector3.new(400000, 400000, 400000)
	while self.flying do
		local point = camera.CFrame.p
		if self.floating then
		else
			self.BodyPosition.Position = self.humanoid.Position + ((self.humanoid.Position - point).unit * self.speed)
		end

		self.BodyGyro.CFrame = CFrame.new(point, self.humanoid.Position)
		RunService.RenderStepped:wait()
	end
end

function FlyScript:endFlying()
	self.BodyPosition.MaxForce = Vector3.new()
	self.BodyGyro.MaxTorque = Vector3.new()
	self.flying = false
end

function FlyScript:startFloating()
	self.floating = true
end

function FlyScript:endFloating()
	self.floating = false
end

return FlyScript