for p,E in pairs(settingVals)do if E~=nil then E.Changed:connect(function()if E.Value==itemName and(script.Parent.Parent.Player.Value==plr and(script.Parent.ItemType.Value~="\069\109\111\116\101"and itemName~=""))then script.Parent.GreenEdge.Visible=true else if itemName==""and script.Parent.ItemType.Value=="\084\111\121"then local p=false for E,u in pairs(settingVals)do if u.Value~=""then p=true break end end if p then script.Parent.GreenEdge.Visible=false else script.Parent.GreenEdge.Visible=true end else local p=false for E,u in pairs(settingVals)do if u.Value==itemName then p=true break end end if not p then script.Parent.GreenEdge.Visible=false else script.Parent.GreenEdge.Visible=true end end end end)if E.Value==itemName and(script.Parent.Parent.Player.Value==plr and(script.Parent.ItemType.Value~="\069\109\111\116\101"and(script.Parent.ItemType.Value~="\084\111\121"or itemName~="")))then script.Parent.GreenEdge.Visible=true plr.PlayerGui.MainGui.Inventory.MainFrame.Preview.Item.Value=actualItem end end end
-- Go through each setting value
for _, i in pairs(settingVals) do
	-- Make sure not nil
	if i ~= nil then
		-- Connect changed event
		i.Changed:connect(function()
			-- Set border to be on if this item
			if
				i.Value == itemName
				and script.Parent.Parent.Player.Value == plr
				and script.Parent.ItemType.Value ~= "Emote"
				and itemName ~= ""
			then
				-- Turn on border
				script.Parent.GreenEdge.Visible = true
			else
				-- Check if equip nothing as toy button
				if itemName == "" and script.Parent.ItemType.Value == "Toy" then
					-- Check if equipped anywhere
					local equipped = false
					for _, o in pairs(settingVals) do
						if o.Value ~= "" then
							equipped = true
							break
						end
					end

					-- Only turn on border if nothing equipped
					if equipped then
						script.Parent.GreenEdge.Visible = false
					else
						script.Parent.GreenEdge.Visible = true
					end
				else
					-- Check if equipped anywhere
					local equipped = false
					for _, o in pairs(settingVals) do
						if o.Value == itemName then
							equipped = true
							break
						end
					end

					-- Set border accordingly
					if not equipped then
						script.Parent.GreenEdge.Visible = false
					else
						script.Parent.GreenEdge.Visible = true
					end
				end
			end
		end)

		-- Set up
		if
			i.Value == itemName
			and script.Parent.Parent.Player.Value == plr
			and script.Parent.ItemType.Value ~= "Emote"
			and (script.Parent.ItemType.Value ~= "Toy" or itemName ~= "")
		then
			script.Parent.GreenEdge.Visible = true
			plr.PlayerGui.MainGui.Inventory.MainFrame.Preview.Item.Value = actualItem
		end
	end
end
