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

Help! Why does math.random always return the same value on a plugin? Multiple methods all fail

Asked by 3 years ago

whats happening is when the plugin is launched it chooses from several songs, however each time it launches it picks the same song each time, I have tried math.randomseed with different values ("ie, mathrandom(tick())") but they dont work

local PLAYLIST = {"rbxassetid://##########","rbxassetid:///##########","rbxassetid:///##########","rbxassetid:///##########","rbxassetid:///##########"}
math.randomseed(tick())
local SONG = PLAYLIST[math.random(5, #PLAYLIST)]

here is the code used right now

this is an on going bug that is hampering me so any assistance is appreciated!

0
try math.random(1,#PLAYLIST) smidgesrev 54 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Its always the last song of the table that is palying right? Because your math.random cmd is running through which song in the table to play, and only has one option -> the 5th song

local SONG = PLAYLIST[math.random(1, #PLAYLIST)]
Ad

Answer this question