THROW_MULTIPLIER=.25 local a={}a.MouseButton1=function(a,n)local t=n[1]local H=a:FindFirstChildOfClass("\084\111\111\108")if not H:FindFirstChild("\068\105\115\112\108\097\121")then return end;(a.Humanoid:LoadAnimation(script.Toss)):Play()task.wait(.3)local O=Instance.new("\077\111\100\101\108",workspace.Debris)O.Name=a.Name..("\095"..script.Name)local z=H:Clone()z.Display.Parent=O z.Handle.Parent=O z:Destroy()local L=H.Display L.Parent=ServerStorage.PlayerStorage local N=100*THROW_MULTIPLIER local r=O.Handle local A=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")A.Velocity=(t-r.Position).unit*N+Vector3.new(0,50,0)A.P=math.huge A.Parent=r local i i=r.Touched:Connect(function(n)if n:IsDescendantOf(workspace.Enemies)and n.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")then local t=n.Parent local H=a:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")i:Disconnect()Ragdoll.Toggle(t)O:Destroy()local z=ServerStorage.Models.NetDisplay:Clone()z.Parent=workspace.Debris z:MoveTo((t.HumanoidRootPart.CFrame*CFrame.new(0,5,0)).Position)end end)local T=.5 wait(T)A:Destroy()task.wait(5)L.Parent=H end a.Z=function(a)print("\104\097\105 \090")end a.X=function(a)print("\104\097\105 \088")end return a
--- VARIABLES/CONSTANTS ---

THROW_MULTIPLIER = 0.25

local Tool = {}

Tool.MouseButton1 = function(Character, ExtraData) -- Throw
	local MousePosition = ExtraData[1]
	local Net = Character:FindFirstChildOfClass("Tool")

	if not Net:FindFirstChild("Display") then
		return
	end

	Character.Humanoid:LoadAnimation(script.Toss):Play()

	task.wait(0.3)

	local Model = Instance.new("Model", workspace.Debris)
	Model.Name = Character.Name .. "_" .. script.Name
	local CloneNet = Net:Clone()
	CloneNet.Display.Parent = Model
	CloneNet.Handle.Parent = Model
	CloneNet:Destroy()

	local Display = Net.Display
	Display.Parent = ServerStorage.PlayerStorage

	-- Throw Model.Handle
	local throwForce = 100 * THROW_MULTIPLIER -- Adjust this value to change the throwing force

	local Handle = Model.Handle -- Assuming the net's handle is named "Handle"
	local BodyVelocity = Instance.new("BodyVelocity")
	BodyVelocity.Velocity = (MousePosition - Handle.Position).unit * throwForce + Vector3.new(0, 50, 0)
	BodyVelocity.P = math.huge -- Sets linear damping to zero so the net doesn't slow down over time
	BodyVelocity.Parent = Handle

	local Connection
	-- Connect touch function, trip enemy
	Connection = Handle.Touched:Connect(function(hit)
		if hit:IsDescendantOf(workspace.Enemies) and hit.Parent:FindFirstChild("Humanoid") then
			local VictimCharacter = hit.Parent
			local Humanoid = Character:FindFirstChildOfClass("Humanoid")

			Connection:Disconnect()

			Ragdoll.Toggle(VictimCharacter)

			Model:Destroy()

			-- Clone ServerStorage.Models.NetDisplay above the enemy to simulate the net falling on top of it, use its handle to cframe it
			-- This will be the visual representation of the net trapping the enemy
			local NetDisplay = ServerStorage.Models.NetDisplay:Clone()
			NetDisplay.Parent = workspace.Debris
			NetDisplay:MoveTo((VictimCharacter.HumanoidRootPart.CFrame * CFrame.new(0, 5, 0)).Position)

			--game.Debris:AddItem(NetDisplay, 10)
		end
	end)

	-- Optionally, you can remove the BodyVelocity after a certain amount of time
	local removeDelay = 0.5 -- Adjust this value to change the delay before removing the BodyVelocity
	wait(removeDelay)
	BodyVelocity:Destroy()

	task.wait(5)

	Display.Parent = Net
end
Tool.Z = function(Character)
	print("hai Z")
end
Tool.X = function(Character)
	print("hai X")
end

return Tool
