How to suppress warnings?

Now, this issue is not quite critical, but it is really annoying me a lot. What’s happening is I am having the script analysis say that a global could be local. When I set the value to local though, a call to the same value later in the same function says that it’s an unknown variable. It’s not a huge issue, but it really bothers me and clutters up my script analysis. How do I fix this?

Code: (Local Script)

button = script.Parent
event = game.ReplicatedStorage.DescriptionEvent
craftingEvent = game.ReplicatedStorage.CraftingEvent
player = game.Players.LocalPlayer

recipies = {
	Axe = {
		"01Handle";
		"01Axehead";
	};
	AxeBlade = {
		"01Stick";
	};
	AxeHead = {
		"01Axeblade";
		"01Stick";
	};
	CampfireKit = {
		"03Log";
		"05Rock";
	};
	CornSeed = {
		"01Corn";
	};
	GrassLeftShortPantLeg = {
		"01Grass";
	};
	GrassRightShortPantLeg = {
		"01Grass";
	};
	GrassLeftShortSleve = {
		"01Grass";
	};
	GrassRightShortSleve = {
		"01Grass";
	};
	GrassShirt = {
		"03Grass";
		"01Twine";
	};
	Handle = {
		"01Stick";
	};
	HeaterKit = {
		"20Rock";
	};
	Kindling = {
		"01Grass";
	};
	PickaxeBlade = {
		"01Stick";
	};
	Pickaxe = {
		"01Handle";
		"01Pickaxehead";
	};
	PickaxeHead = {
		"01Stick";
		"02Pickaxeblade";
	};
	Stick = {
		"01Log";
	};
	Torch = {
		"01Kindling";
		"01Handle";
	};
	Twine = {
		"01Grass";
	};
}
item1Count = 0
item2Count = 0
item3Count = 0

event.Event:Connect(function(_, obj)
	item = obj:gsub("%s+", "")
end)

button.MouseButton1Click:Connect(function()
	local recipie = recipies.Torch --recipies[item]
	local inv = player.Backpack
	local materialsPresent = 0
	local item1Name = string.sub(recipie[1], 3, -1)
	local item1Needed = string.sub(recipie[2], 1, 2)
	if recipies[2] then
		item2Name = string.sub(recipie[2], 3, -1)
		item2Needed = string.sub(recipie[2], 1, 2)
	else
		item2Name = "None"
		item2Needed = 0
	end
	if recipies[3] then
		item3Name = string.sub(recipie[3], 3, -1)
		item3Needed = string.sub(recipie[3], 1, 2)
	else
		item3Name = "None"
		item3Needed = 0
	end
	local items = inv:GetChildren()
	if not inv then
		print("Error: Inventory Not Found")
	else
		for i = 1, #items do
			if items[i].Name == item1Name then
				item1Count = item1Count + 1
			elseif items[i].Name == item2Name then
				item2Count = item2Count + 1
			elseif items[i].Name == item3Name then
				item3Count = item3Count + 1
			end
		end
		if item1Count >= item1Needed and item2Count >= item2Needed and item3Count >= item3Needed then
			print("Firing Server")
			if item == "Stick" then productCount = 4
			elseif item == "CornSeed" then productCount = 2 
			else productCount = 1 end
			event:FireServer(item1Name, item1Needed, item2Name, item2Needed, item3Name, item3Needed, productCount, productName)
		end
	end
end)
1 Like

Try localizing the variables at the top of the script (outside of any functions, not necessarily at the exact top). Just set its value to nil, or do local varName;.

2 Likes