The Goal
So what I am trying to do is to make a minigame place. It checks if the minigame has a pointbrick and if it does then it means that the minigame is a race. We have to detect when that brick is touched so then when touched it will end the minigame.
The Problem I am not experienced with the 'return' code so can you help with this? The Code
function round()
local minigames = game.Lightning:GetChildren()
local map = minigames[number]
local number = math.random(1, #minigames)
local spawns = map.Spawns.GetChildren()
local pointbrick = map.PointBrick
for intermission = 25,1,-1 do
game.Workspace.Timer.Value = "Intermission: "..intermission
end
game.Workspace.Timer.Value = "The game will start shortly."
wait(3)
game.Workspace.Timer.Value = "Choosing Minigame..."
wait(3)
game.Workspace.Timer.Value = "Minigame: "..map.Name
wait(3)
game.Workspace.Timer.Value = "Loading Minigame..."
wait(3)
mapModel = map:clone()
mapModel.Parent = Workspace
game.Workspace.Timer.Value = "Teleporting players..."
wait(1)
for _, player in pairs(game.Players:GetPlayers()) do
local character = player.Character
local randomSpawn = spawns[math.random(#spawns)] -- EDIT
if character then
character:MoveTo(randomSpawn.Position) -- EDIT
end
end
wait(1)
for readySetGo = 3,1,-1
game.Workspace.Timer.Value = readySetGo
wait(1)
end
game.Workspace.Timer.Value = "Go!"
for timer = 150,1,-1 do
if pointbrick then
function endRoundAuto()
game.Workspace.Timer.Value = "Game over!"
mapModel:remove()
wait(3)
return round
end
end
game.Workspace.Timer.Value = "Time left: "..timer
end
if pointbrick then
game.Workspace.Timer.Value = "Nobody won. Too bad."
mapModel:remove()
wait(3)
return true
else
game.Workspace.Timer.Value = "Game over! Winners get __ points!"
mapModel:remove()
wait(3)
return true
end
end
if pointbrick then
pointbrick.Touched:connect(endRoundAuto)
end

2 comments
Dude... look down.
Dude, the one I want is cut short.