Attempt to index local 'ply' (a nil value)

[lua]
function CashOut( ply )
ply:PrintMessage( HUD_PRINTTALK, “You got paid 15$” )
end
timer.Create( “CashOutTimer”, 5, 0, CashOut, ply )
[/lua]

I have no idea why i keep getting the “attempt to index local ‘ply’ (a nil value)” when i start the gamemode, any ideas how to fix it?

[lua]function CashOut()
for k,v in pairs (player.GetAll()) do
v:PrintMessage( HUD_PRINTTALK, “You got paid 15$” )
end
end
timer.Create( “CashOutTimer”, 5, 0, CashOut, ply )[/lua]

Adding ply as a function argument to CashOut isn’t going to make Lua magically know that it is a player entity. You need to define it, if you want to do this to every player on the server use this:
[lua]function CashOut( ply )

for k, v in pairs( player.GetAll( ) ) do
	v:PrintMessage( HUD_PRINTTALK,  "You got paid 15$"  )
end

end
timer.Create( “CashOutTimer”, 5, 0, CashOut )[/lua]

[editline]02:08PM[/editline]

You almost beat me, but you have a missing ‘end’.

Thanks, didnt have time to correct it. And seeing your code makes me want to go and learn indenting.

Or, if you do not want to send it to all the players on the server, add:
[lua]local ply = LocalPlayer()[/lua] at the top of the function.