Why doesnt this work?

Try this:

local player = game.Players.LocalPlayer
local inv = game.ReplicatedStorage.PlayerInvetorys:WaitForChild(player.Name .. "Folder")
local CurrentInv = inv:GetChildren()
local C = script.Parent.ItemFrame
local hoverinv = script.Parent.Parent.HoverInfo
local mouse = player:GetMouse()

print(CurrentInv)

hoverinv:SetAttribute("AmountSelectedBy",0)

local connections = {}

function equipitem(item)
	if not item then warn("Wheres My Gun At?") return end
	game.ReplicatedStorage.TotallyCoolEvents.EquipGun:FireServer(item)
end

for i, v in ipairs(CurrentInv) do
	local K = C:Clone()
	K.Text = v.Name
	K.Visible = true
	K.Parent = C.Parent
	K.MouseButton1Click:Connect(function()
		equipitem(v)
		K:Destroy()
	end)

	K.MouseEnter:Connect(function()
		hoverinv.Visible = true
		hoverinv:SetAttribute("AmountSelectedBy",hoverinv:GetAttribute("AmountSelectedBy")+1)
	end)

	K.MouseLeave:Connect(function()
		hoverinv:SetAttribute("AmountSelectedBy",hoverinv:GetAttribute("AmountSelectedBy")-1)
		if (hoverinv:GetAttribute("AmountSelectedBy") == 0) then
			hoverinv.Visible = false
		end
	end)
	
	table.insert(connections,K)
end

inv.ChildAdded:Connect(function(Child)
	local K = C:Clone()
	K.Text = Child.Name
	K.Visible = true
	K.Parent = C.Parent
	K.MouseButton1Click:Connect(function()
		equipitem(Child)
		K:Destroy()
	end)
	
	if (not connections[K]) then
		K.MouseEnter:Connect(function()
			hoverinv.Visible = true
			hoverinv:SetAttribute("AmountSelectedBy",hoverinv:GetAttribute("AmountSelectedBy")+1)
		end)

		K.MouseLeave:Connect(function()
			hoverinv:SetAttribute("AmountSelectedBy",hoverinv:GetAttribute("AmountSelectedBy")-1)
			if (hoverinv:GetAttribute("AmountSelectedBy") == 0) then
				hoverinv.Visible = false
			end
		end)
	end
end)

mouse.Move:Connect(function()
	hoverinv.Position = UDim2.new(0,mouse.X,0,mouse.Y)
end)

eh, at this point its probably just a problem with roblox, tried it and it still yields the same results as before

1 Like

Ah alright. I’ll link you this module I found.
It might help you with better detection. Sorry I couldn’t help.