Hello! I am making a mainscript for my game I am making called Maze Runner, and it is going great! However, I cannot find a correct method of how to end the 'minigame' correctly. I was wandering if the community could help! here is my code:
minigames = game.Lighting.Mazes:GetChildren()
h = Instance.new("Hint", game.Workspace)
so = Instance.new("Sound", game.Workspace)
so.SoundId = "http://www.roblox.com/asset/?id=142731047"
so:Play()
print("MazeRunnerMain Script has loaded and the games are about to begin")
while true do
if game.Players.NumPlayers > 1 then
for i = 60,1,-1 do
h.Text = "You have " ..i.. " Seconds left to prepare."
wait(1)
end
h.Text = "Choosing a Maze..."
wait(3)
h.Text = "Almost there..."
wait(2)
h.Text = "Ah! Found one!"
wait(2)
rangame = math.random(1, #minigames)
gameChosen = minigames[rangame]
h.Text = "Loading map..."
wait(2)
gameChosenClone = gameChosen:Clone()
wait(2)
h.Text = "Done!"
gameChosenClone.Parent = game.Workspace
wait(3)
so:Stop()
wait()
so.SoundId = "http://www.roblox.com/asset/?id=150508897"
wait()
so:Play()
h.Text = "Make it to the end of the maze for the Riches of a lifetime, if you dare..."
--how to end game on Touched?
h.Text = "Game Over!"
gameChosenClone:Destroy()
wait(5)
so:Stop()
wait()
so.SoundId = "http://www.roblox.com/asset/?id=142731047"
wait()
so:Play()
else
h.Text = "You need another Adventurer in order to Enter The Maze!"
end
wait()
end
My issue is near the comment that says "--How to end on Touch?" Please help soon and Thanks!

2 comments
once I step on the part, the game loop constantly ends the game instead of letting the brick be stepped on at all. Please Help!
I REALLY NEED AN ANSWER!