updateInputHoldEvent.OnServerEvent:Connect(onUpdateInputHoldEvent)updateHoverObjectEvent.OnServerEvent:Connect(onUpdateHoverObjectEvent)equippedGunIndexVal.Changed:Connect(function()onUpdateHoverObjectEvent(ply,mouseHoverObjectVal.Value or nil)end)downedVal.Changed:Connect(onDown)local function d()local d=BMM.getCharacterCurrentHoldingParts(char)for d,M in pairs(d)do BMM.dropPartFromInventory(char,M)end end local M=nil local b=nil M=game.Players.PlayerRemoving:Connect(function(f)if ply~=f then return end if M then M:Disconnect()end if b then b:Disconnect()end d()end)b=hum.Died:Connect(function()if M then M:Disconnect()end if b then b:Disconnect()end d()end)
--

updateInputHoldEvent.OnServerEvent:Connect(onUpdateInputHoldEvent)
updateHoverObjectEvent.OnServerEvent:Connect(onUpdateHoverObjectEvent)
equippedGunIndexVal.Changed:Connect(function()
	onUpdateHoverObjectEvent(ply, mouseHoverObjectVal.Value or nil)
end)
downedVal.Changed:Connect(onDown)

local function dropAllParts()
	local parts = BMM.getCharacterCurrentHoldingParts(char)
	for _, partVal in pairs(parts) do
		BMM.dropPartFromInventory(char, partVal)
	end
end

local leaveConn = nil
local diedConn = nil

leaveConn = game.Players.PlayerRemoving:Connect(function(player)
	if ply ~= player then return end
	if leaveConn then leaveConn:Disconnect() end
	if diedConn then diedConn:Disconnect() end
	dropAllParts()
end)

diedConn = hum.Died:Connect(function()
	if leaveConn then leaveConn:Disconnect() end
	if diedConn then diedConn:Disconnect() end
	dropAllParts()	
end)
