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

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

Asked by
gitrog 326 Moderation Voter
6 years ago
Edited 6 years ago

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()

0
Try math.randomseed(tick()%1*1e6) credit to @Uglypoe  Azarth 3141 — 6y
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? GoldenPhysics 474 — 6y
0
try using math.randomseed(tick(os.time())) or something like that.... greatneil80 2647 — 6y
0
math.randomseed rounds its input to the nearest whole number. XAXA 1569 — 6y

1 answer

Log in to vote
0
Answered by
Nowaha 459 Moderation Voter
6 years ago
Edited 6 years ago

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...

0
Also, do not use ; but use , Nowaha 459 — 6y
0
Either way works. Its how the developer prefers. Thundermaker300 554 — 6y
Ad

Answer this question