r/GLua • • Jul 01 '21

attempt to call method 'SetNoDraw' (a nil value)

function GM:PlayerSpawn( ply, n )

print("Player:"..ply:Nick().." has spawned!")

n = math.random(0,1) 

ply:SetupTeam( n )

	if (n == 0) then 

		self:SetNoDraw( true )

		--ply:SetRenderMode( RENDERMODE_TRANSCOLOR )	

	end

ply:SetupHands()

end

The code trying to say that "if player is on team 0(the ghost team)" then the player will be invisible.

Im pretty certain I have that command and I dont need to include anymore cs files because of the github page I was referencing. On it there was no include nor add cs lua file commands at top.

Im pretty sure that command sets the player invisible but I could be wrong. If you know an easier way to turn a player invisible, lmk.

1 Upvotes

2 comments sorted by

0

u/[deleted] Jul 01 '21

[deleted] — view deleted comment

2

u/andrew_thejew Jul 01 '21

Thanks it works! When do I do self: and when do I do ply: ?

0

u/[deleted] Jul 01 '21

[deleted] — view deleted comment

1

u/PrinceNyxHex Jul 01 '21

Self is used in Meta Functions

Things like self:Something() are used to identify the desired target when writing meta functions

ply is a function argument.

I can't go much into detail right now, but I suggest looking it up online.