So the this minigame is suppose to work is if all candles are lit (clicked on) before the time runs out, the game will display a hint telling the players that all candles were lit, but if some candles were not lit the game would display a hint that the players had failed, this is sort of like the sketch for the final product so I am not adding anything to the script that will kill the players for failing/winning or anything that rewards players for winning quite yet. but when i run the game, everything goes well until the time runs out and it stops the script and doesn't tell the players if they won or lost, candles are in the map and the code for the candles are
local candle = script.Parent local fire = candle.Part.Fire local light = candle.Part.PointLight local function OnClick() fire.Enabled = true light.Enabled = true end candle.ClickDetector.MouseClick:connect(OnClick)
The code for the minigame script itself =
minigames = game.Lighting.Minigames:GetChildren() candles = game.Lighting.Minigames.Map.Candles: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 for i = 10, 1, -1 do h.Text = "Time left: " .. i wait(1) end h.Text = "Time is up..." wait (1) if candles.Part.Fire.Enabled == true 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 wait(3) gameChosenClone:Destroy() end wait(1) end
Using :GetChildren() returns an object table of something's children. So, you have to loop through the table in order to check.
minigames = game.Lighting.Minigames:GetChildren() candles = game.Lighting.Minigames.Map.Candles: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 for i = 10, 1, -1 do h.Text = "Time left: " .. i wait(1) end h.Text = "Time is up..." wait (1) lit = true for _, v in pairs (candles) do -- Loop through the children if v.Part.Fire.Enabled == true then lit = false break end end if lit 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 wait(3) gameChosenClone:Destroy() end wait(1) end