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

Randomizer has a fixed sequence? (images)

Aight, so i have made this image randomiser which will display a random image when you click this button;

math.randomseed(tick(1))

local Ids = game.ServerStorage:WaitForChild('Banner1'):GetChildren() local Player = script.Parent.Parent.Parent.Parent local Background = script.Parent.Parent:WaitForChild('Background') local RImage = Background:WaitForChild('RandomImage') local RText = Background:WaitForChild('RandomText') local Randomized = false local Requirement = 10

script.Parent.MouseButton1Click:Connect(function() if Randomized == false and Player.extra.DragonStones.Value >= Requirement then Randomized = true Player.extra.DragonStones.Value = Player.extra.DragonStones.Value - Requirement local ID = Ids[math.random(2, #Ids)] Background.Visible = true RImage.Image = ID.Texture RText.Text = "You have summoned "..ID.Name wait(5) Background.Visible = false Randomized = false end end)

But when I click randomize, it always outputs with the same sequence of images, going from Tree>Tree>Doll>Ghost EACH time.? Help pls?

1 answer

This is because the math.random function is only psuedo random. the seed is a random number that creates a list of random numbers afterward, so if the have the same the seed every time the numbers created will always be the same.

if you want to create a better randomizer try doing

math.randomseed(os.time())

this takes the current time and uses that as the seed so it is always different.

let me know if this helps

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