Simple lua help

So, I am trying to set it so when an admin joins, they get infinite money in Darkrp. In darkrp, infinite money only lasts 1 instance, so I would have it so every time you join, it sets admins to have infinite money. I am trying to make that code, and i am new to lua coding, so i was wondering if i could get some help. The console command for setting money is


rp_setmoney NAME AMOUNT

so i would want


rp_setmoney Bazoogle inf

I made this


hook.Add( "PlayerConnect", "test", function( ply )
	if ( ply:IsAdmin() ) then
	concommand.Run( self, rp_setmoney, inf )
	Msg("Money set")
	else
	Msg("You are not an admin")
end
end)

and put it in lua/autorun/client and I have no idea what to set the target to… Could anyone help?

ply:Name() though it will fuck up if the player got weird characters in its name

You should put it into lua/autorun/server

I’m new to Lua coding myself but maybe you could use the “ply” variable, if it’s the cl_init file then maybe use “LocalPlayer”? I’m not too sure myself.

PlayerConnect only passes string name, string ip; in that order. Use the PlayerInitialSpawn hook instead. I would also advise using RunConsoleCommand


RunConsoleCommand("rp_setmoney", ply:Nick(), 1000000000000)

Put this in lua/autorun/server.

-snip-

without using the command, you could also use ply:addMoney(amount)