Changing players materials based on team

Hey guys, I’m trying to make it so all members of a certain team are a certain material. I have this in shared.lua

However it just gives me this error:

[ERROR] gamemodes/ghostbusters/gamemode/shared.lua:22: ‘<eof>’ expected near ‘end’

  1. unknown - gamemodes/ghostbusters/gamemode/shared.lua:0

Any help would be greatly appreciated. Thanks.

[lua]function GM:PlayerInitialSpawn( ply )
self.BaseClass:PlayerInitialSpawn( ply )
ply:SetTeam ( team.BestAutoJoinTeam() )

if ply:Team() == 2 then


To expand from Ice Tea

<eof> means end of function. you just forgot to close your function.

“If” statements need their own end too

Alright, so I did that but now I get this
[ERROR] gamemodes/ghostbusters/gamemode/shared.lua:20: attempt to call local ‘ply’ (a userdata value)

  1. unknown - gamemodes/ghostbusters/gamemode/shared.lua:20

Does this mean it would maybe work in player.lua?

EDIT: Tried it, still no go with the material.


ply doesn’t need a ()

So try


EDIT: code tags aren’t working, you get the idea

Alright I’ll try it

EDIT: Works, thanks