[Lua] Help - Trying to make npcs when spawned generate with a random amount of health
5 replies, posted
Hello,
I am looking for some help with lua. As stated it the title I'm trying to make it where one a npc is spawned (via the npc tab) with a randomly generated amount of health.
I belive the code itself was
[code]math.random(10000,20000)[/code]
I would also like to know the file location of where I would put the code/how to run it.
Thank You.
Usually helps to google around a bit.
[url]http://wiki.garrysmod.com/page/Entity/SetHealth[/url]
[QUOTE=Nookyava;43268215]Usually helps to google around a bit.
[url]http://wiki.garrysmod.com/page/Entity/SetHealth[/url][/QUOTE]
Is there a way to randomize the health?
[CODE]
local rand = math.random( 100 ) --random integer between 1 and 100
Ent:SetHealth( rand )
[/CODE]
Use the wiki. Pretty sure you're smart enough to find something to use on it.
[QUOTE=CallMePyro;43268282][CODE]
local rand = math.random( 100 ) --random integer between 1 and 100
Ent:SetHealth( rand )
[/CODE][/QUOTE]
Thanks!
Sorry, you need to Log In to post a reply to this thread.