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

Minigame script breaking when more than one player joins the game?

Candle minigame error, starts when more than one player joins, skips picking map, starts timer end with Time is up.... and breaks the whole script, not sure how to fix it.

minigames = game.Lighting.Minigames:GetChildren()
h = Instance.new("Hint",game.Workspace)
while true do
    if game.Players.NumPlayers > 0 then
        h.Text = "Picking random map..."
        wait(3)
        ranGame = math.random (1, #minigames)
        gameChosen = minigames[ranGame]
        h.Text = "Minigames Chosen:" .. gameChosen.Name
        wait(3)
        gameChosenClone = gameChosen:Clone()
        gameChosenClone.Parent = game.Workspace

	
wait(2)
end

plrs = game.Players:GetChildren()
    for i = 1, #plrs do
            plrs[i].Character:MoveTo(gameChosen.Spawn.Position)
        for i = 15, 1, -1 do
            h.Text = "Time left: " .. i
            wait(1)
        end
        h.Text = "Time is up..."
        wait (1)

		candles  = gameChosenClone.Candles:GetChildren()

        
        for _, v in pairs(candles) do -- Loop through the children
            if v.Part.Fire.Enabled == true then
                islit = true
				else islit = false
                break
            end
        end

        if islit then
            h.Text = "All the candles have been lit!, the Demon has decided not to come!"
        else 
            h.Text = "Not all of the candles were lit!, you have failed"
        end

print(islit)
        wait(3)
        gameChosenClone:Destroy()
    end
    wait(1)
end

1 answer

End your loops

Your Player moving loop continues on for way too long.

plrs = game.Players:GetChildren()
    for i = 1, #plrs do
            plrs[i].Character:MoveTo(gameChosen.Spawn.Position)
	end
        for i = 15, 1, -1 do
            h.Text = "Time left: " .. i
            wait(1)
        end
        h.Text = "Time is up..."
        wait (1)

        candles  = gameChosenClone.Candles:GetChildren()


        for _, v in pairs(candles) do -- Loop through the children
            if v.Part.Fire.Enabled == true then
                islit = true
                else islit = false
                break
            end
        end

        if islit then
            h.Text = "All the candles have been lit!, the Demon has decided not to come!"
        else 
            h.Text = "Not all of the candles were lit!, you have failed"
        end

print(islit)
        wait(3)
        gameChosenClone:Destroy()
    wait(1)

8 comments

0

It seems adding the end broke the script entirely.

0

You forgot to remove the other end.

0

where is the other end?, Im not sure which end im suppose to remove.

0

The one causing the end.

0

It seems to still not work, i checked output and it expects an end at line 50, but still doesnt work

0

Do you understand what it does?

0

Not exactly, im pretty confused right now lol

0

Then I can't help you. If you can't understand your own code, it's not my problem.

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