I need help with number and math.random syntax

local PlayerModel = {}
PlayerModel[1] = “models/player/arctic.mdl”
PlayerModel[2] = “models/player/leet.mdl”
PlayerModel[3] = “models/player/guerilla.mdl”
PlayerModel[4] = “models/player/phoenix.mdl”

CLASS.PlayerModel = “PlayerModel”…math.random(1, 4)

This i like the main problem that’s worry me i dont think this is working correctly

CLASS.PlayerModel = “models/player.mdl”
this is the main one a simple model selector but i need a selector that randomly select 1 to 4
does anyone know how to fix it?


(User was banned for this post ("Wrong section" - mahalis))

CLASS.PlayerModel = PlayerModel[math.random(1,4)];

CLASS.PlayerModel = table.Random( PlayerModel )

This works aswell

It would, but he mentioned math.random. Might aswell use that.
Doesn’t table.Random just return
math.random(1,#argument)?

table.Random picks a number n from 1 to table.Count and loops through the table (returning the nth element) to ensure that tables with string keys or tables that are not index sequentially.

That was close enough.