!v:alive and v:alive

So this code:
function GM:RoundEnd( )
local LoseSound = { “vo/npc/Barney/ba_no01.wav”, “vo/npc/Barney/ba_no02.wav”, “vo/npc/male01/no01.wav”, “vo/npc/male01/no02.wav” }
local WinSound = { “vo/npc/female01/yeah02.wav”, “vo/npc/male01/yeah02.wav” }
for k,v in pairs(player.GetAll()) do
if !v:Alive() and !v:Team() == TEAM_SPECTATOR then
v:SendLua( “surface.PlaySound( “” … table.Random(LoseSound) … “” )” )
v:ChatPrint(“You failed, the other team has won the round.”)
elseif v:Alive and !v:Team() == TEAM_SPECTATOR then
v:SendLua( “surface.PlaySound( “” … table.Random(WinSound) … “” )” )
v:ChatPrint(“You won, the other team has lost the round.”)

there is a !v:Alive and a regular v:Alive
What does the ! do?

It’s the negation operator.

Basically it’s like saying “if not alive then”.

Oh ok thanks :smiley:

You’re welcome.


local a = true

if a then print(“a = true”) end
if !a then print(“a = false”) end


local a = true

if a then print( “a = true” )
elseif !a then print( “a = false” ) end

Just for future reference.