'then' expected near 'in'

Hello, I come to you people with a problem.


local function AddClassIcon(Model, description, class, command)
	if LocalPlayer():Team() in class then
		local icon = vgui.Create("SpawnIcon")
		icon:InvalidateLayout( true ) 
		icon:SetModel(Model)
		icon:SetIconSize(64)
		icon:SetToolTip(description)
		icon.DoClick = function() LocalPlayer():ConCommand("say "..command) end
		WepPanel:AddItem(icon)
	end
end
AddClassIcon("models/weapons/w_mach_m249para.mdl", "Buy Para $600", TEAM_POLICE, "/buyammo pistol")

Error:


[gamemodes\darkrp\gamemode\showteamtabs.lua:653] 'then' expected near 'in'
[gamemodes\darkrp\gamemode\init.lua:54] ERROR PARSING CLIENTSIDE FILE: 'DarkRP\gamemode/showteamtabs.lua'

I’m wondering why its saying this when there is a then :frowning:

You’re mixing up 2 things :

The if statement ( “if [true] then … End” )

And the for loop ( “for var in pairs( table ) do … End” )


local function AddClassIcon(Model, description, class, command)
	if LocalPlayer():Team() == class then
		local icon = vgui.Create("SpawnIcon")
		icon:InvalidateLayout( true ) 
		icon:SetModel(Model)
		icon:SetIconSize(64)
		icon:SetToolTip(description)
		icon.DoClick = function() LocalPlayer():ConCommand("say "..command) end
		WepPanel:AddItem(icon)
	end
end
AddClassIcon("models/weapons/w_mach_m249para.mdl", "Buy Para $600", TEAM_POLICE, "/buyammo pistol")

try that.