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 U()local U=BMM.getCharacterCurrentHoldingParts(char)for U,j in pairs(U)do BMM.dropPartFromInventory(char,j)end end local j=nil local H=nil j=game.Players.PlayerRemoving:Connect(function(A)if ply~=A then return end if j then j:Disconnect()end if H then H:Disconnect()end U()end)H=hum.Died:Connect(function()if j then j:Disconnect()end if H then H:Disconnect()end U()end)
--[[---------------- CONNECTIONS -----------------]]
--

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)
