Script Not Running But No Erros

In my equipping system I’m currently testing out, the script add 1 when it’s supposed to but never removes 1 from EquippedTools. What can I do to fix it?

local MaxTools = 5
local EquippedTools = 0

for _, Tool in ipairs(script.Parent:GetChildren()) do
	if Tool:IsA("Frame") and Tool:GetAttribute("Parent") == "Items" then
		Tool:GetAttributeChangedSignal("Equipped"):Connect(function()
			if Tool:GetAttribute("Equipped", false) and EquippedTools < MaxTools then
				game.ReplicatedStorage.Events.Misc.EquipTool:FireServer(Tool.Name)
				
				Tool:SetAttribute("Equipped", true)
				
				EquippedTools += 1
			elseif Tool:GetAttribute("Equipped", true) then
				game.ReplicatedStorage.Events.Misc.UnequipTool:FireServer(Tool.Name)

				Tool:SetAttribute("Equipped", false)

				EquippedTools -= 1
			elseif EquippedTools > MaxTools then
				game.ReplicatedStorage.Events.Notifications.MessageOnScreen:FireServer("Hey!", "You can only have 5 tools equipped at once. Please unequip another tool and try again!", "Green", "Ok")
			end
			print(EquippedTools)
		end)
	end
end

Resolved

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.