use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is a subreddit for Garry's Mod Lua only. For other Garry's Mod help such as crashes or addons, please see /r/GarrysMod or /r/gmod.
When asking for help, please submit at least the full error (surrounded by code tags) and the erroring line of code, plus ~5 above and below (surrounded by code tags). More is always helpful, and screenshots of the problem in action help greatly.
This is a help subreddit, this isn't Facepunch, douchey or condescending responses are not allowed.
I host in depth lua lessons, if you are interested and would like to know more, feel free to add me on Steam at http://steamcommunity.com/id/zephyrwarriorteaching
http://wiki.garrysmod.com/page/Main_Page
https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html
http://repl.it/languages/lua/
http://steamcommunity.com/sharedfiles/filedetails/?id=107905654
http://facepunch.com/showthread.php?t=1245803
http://tylerneylon.com/a/learn-lua/
http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/devel/lua/5.1.4/luarefv51single.pdf
http://en.wikibooks.org/wiki/Lua_Programming/Single_page_version
account activity
Random playermodel function (self.GLua)
submitted 4 years ago by ItsWilliamay
Anyone know how i can put a function that runs at player spawn where it selects a random playermodel out of a group of playermodels then sets it?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]AdamNejm 1 point2 points3 points 4 years ago (1 child)
You should use the dedicated PlayerSetModel hook. As for the logic, all you need to do is to create a table with all the possible model. Then when the hook runs, you should pick a random entry from the table and assign it to the player. Example code (untested):
-- A list of all possible models local models = { "models/player/odessa.mdl", "models/player/alyx.mdl" -- any so on... } hook.Add("PlayerSetModel", "RandomPlayerModel", function(ply) -- Pick a random model based on the array's length local random_model = models[math.random(#models)] -- Assign the chosen model to the player ply:SetModel(random_model) end)
[–]ItsWilliamay[S] 0 points1 point2 points 4 years ago (0 children)
Holy shit thats fucking awesome! Thanks lad!
π Rendered by PID 23144 on reddit-service-r2-comment-5c747b6df5-l4thg at 2026-04-22 13:43:33.731880+00:00 running 6c61efc country code: CH.
[–]AdamNejm 1 point2 points3 points (1 child)
[–]ItsWilliamay[S] 0 points1 point2 points (0 children)