Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

math.random not functioning correctly?

i have 6 npcs, same script, same tables, all pathfinding to houses. when i run the game, i have 2 tables for NPC color and NPC name.

when i run the game they all end up having the same name and color. i even tried math.randomseed(tick()) but nothing has changed.

3 comments

0

Are you changing the Colors and Names all through a single script or through an individual script for each NPC?

0

6 npcs with the same script, same tables, using math.random

0

Show us the code please, it could be that you generate only 1 random value and set all the NPC's to that.

1 answer

Reference a different math.random before the choosing of each name and colour, ex.

local a = math.random(1,5)
print(a)
local b = math.random(1,5)
print(b)

or if you're using a loop you can just redefine the variable every iteration

This discussion is preserved as it was. New answers, comments, and votes are closed.