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

math.randomseed(tick()) always giving me same output?

So, I have a "randomized" number, but every time I start up the server, it's playing the same song. Here's my script. (It's a LocalScript with FilteringEnabled active)

math.randomseed(tick())
local player = game.Players.LocalPlayer

local menuSounds = {
	846744087; --@other devs this song is here as a joke remove this upon release and please don't kill meeeeeeeeeeee -git
	629166622; 
	247050817; 
	130798504; 
	902587196; 
	
}

local soundtrack = Instance.new("Sound")
soundtrack.Parent = player.PlayerGui
soundtrack.SoundId = "rbxassetid://" .. menuSounds[math.random(1,#menuSounds)]
soundtrack.Looped = true
soundtrack.Name = "MenuSound"
soundtrack:Play()

4 comments

0

Try math.randomseed(tick()%1*1e6) credit to @Uglypoe 

0

I've tried before where I call math.random() once and don't use the result of it, and only start using the results of the second call and so on. Try that, perhaps?

0

try using math.randomseed(tick(os.time())) or something like that....

0

math.randomseed rounds its input to the nearest whole number.

1 answer

You do math.randomseed(tick()) and then don't do anything with it? You just do that line but you don't save it or use it for anything later on...

2 comments

0

Also, do not use ; but use ,

0

Either way works. Its how the developer prefers.

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