--[[---------------- 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)
