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

Script stuck as "Choosing game..." How do I fix it?

Asked by 3 years ago

I made a mini game script and it keeps getting stuck at "Choosing game..." does anyone know what the problem is in my script?

Script:

minigames = game.ReplicatedStorage.Minigames:GetChildren() timer = game.StarterGui.IntermissionAndRound.Frame.TimerDisplay

while true do

if game.Players.NumPlayers > 1 then -- if the players in the server are greater than 1 then
    timer.Text = "Choosing game..."
    wait(3)
    rangame = math.random(1, minigames)-- chooses one random minigame   
    gamechosen = minigames[rangame] 
    timer.Text = gamechosen.Name -- the hint tells the player what minigame they are gonna play on
    wait(3)
    gamechosenclone = gamechosen:Clone() -- makes a clone of the minigame
    gamechosenclone.Parent = game.Workspace -- puts the minigame in workspace

    for i = 10, 1, -1 do -- time

        timer.Text = "Time left:" .. i
        wait(1)
    end
    timer.Text = "Round finished!"
    wait(3)
    gamechosenclone:Destroy() -- 3 seconds after round finishes, the minigame clone gets destroyed.

else
    timer.Text = "There needs to be at least 2 people to start"
end
wait(1)

end

1 answer

Log in to vote
0
Answered by 3 years ago

There is an error in this script, when you are randomly picking a map you didnt put a # infront of minigames because minigames is a table.

For example

    rangame = math.random(1, #minigames)

And also the gamechosen variable should be set to just the rangame variable.

Ad

Answer this question