0
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

(I am newbie)I have used this code. But it doesn't work at all. My script is in the gamemode folder and is called "serverscript.lua".Basically, I need the system to automatically change the model to a random one when the player enters the game.

I tried to fix this problem. But unfortunately only errors appeared that clung to "hook.ADD" and other syntax errors. There is absolutely no solution to this problem on the internet.

Here is an article about this class - https://wiki.facepunch.com/gmod/GM:PlayerSetModel

Fix Egg
  • 1
  • 1
  • "script is in the gamemode folder" What is the exact path? Some folders are automatically loaded serverside, others automatically loaded clientside, and others not automatically loaded at all. – Wh1t3rabbit Jun 22 '23 at 05:20
  • GarrysMod\garrysmod\gamemodes\leftfourgz\gamemode\serverscript.lua – Fix Egg Jun 22 '23 at 07:07
  • @Wh1t3rabbit GarrysMod\garrysmod\gamemodes\leftfourgz\gamemode. I will be happy if you help me. I will also add that when this script is triggered, errors appear, and the function that should change the player model does not work. – Fix Egg Jun 22 '23 at 07:17

0 Answers0