I am making a simple minigame test, for a friend, and I made this code:
Script
-- Variables
game.Players.PlayerAdded:Connect(function(player)
local status = game.StarterGui.Status.StatusLabel
local reward = 10
repeat
status.Text = "NEED MORE PLAYERS FOR MINIGAME"
until game.Players.NumPlayers >= 1
if game.Players.NumPlayers >= 1 then
status.Text = "MINIGAME STARTING SOON"
wait(5)
status.Text = "OBJECTS LOADING"
wait(5)
local objects = game:GetService("ServerStorage").Objects:GetChildren()
local clonedObject = objects[(math.random(1,#objects))]:Clone()
clonedObject.Parent = workspace
wait(5)
status.Text = "OBJECTS HAVE BEEN LOADED"
end
end)
The status won’t change, even when the objects have been cloned.
I know it’s a little late and you’ve already got a solution, but the Random class seems to give a little more random results than the math.random() function.
It could just be a placebo and it isn’t actually any more random.
The algorithm used by Random is the XSH-RR variant of the PCG family.
In a nutshell, it’s is a fast algorithm with excellent statistical properties.
We’re planning to change math.random to use the same algorithm by early next year.
I believe this post was made in 2017. It has been 3 year since then, and that change has likely been implemented.
The only reason you might want to use the Random class is for an object oriented approach, or a case where you might need several “random” generators with different seeds.
You did:
local status = game.StarterGui.Status.StatusLabel
Which takes the GUI in the starterGui, not the playerGui. You need to do something like:
local status = game.Players.PlayerNameHere.PlayerGui.Status.StatusLabel