for a,x in pairs(settingVals)do if x~=nil then x.Changed:connect(function()if x.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 a=false for x,B in pairs(settingVals)do if B.Value~=""then a=true break end end if a then script.Parent.GreenEdge.Visible=false else script.Parent.GreenEdge.Visible=true end else local a=false for x,B in pairs(settingVals)do if B.Value==itemName then a=true break end end if not a then script.Parent.GreenEdge.Visible=false else script.Parent.GreenEdge.Visible=true end end end end)if x.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.Preview.Item.Value=actualItem end end end

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.Preview.Item.Value = actualItem
		end
		
	end
	
end
