Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

math.random not functioning correctly?

Asked by 4 years ago

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.

0
Are you changing the Colors and Names all through a single script or through an individual script for each NPC? XxTrueDemonxX 362 — 4y
0
6 npcs with the same script, same tables, using math.random tollepuxis 20 — 4y
0
Show us the code please, it could be that you generate only 1 random value and set all the NPC's to that. BlackOrange3343 2676 — 4y

1 answer

Log in to vote
0
Answered by
Robowon1 323 Moderation Voter
4 years ago
Edited 4 years ago

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

Ad

Answer this question