I am making a marble game, and I want it so whenever a player touches a part, the round ends. Can anyone help me with that? Thank you;
Main Script:
local roundLength = 10 -- usually 60
local intermissionLength = 10 -- usually 25
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local MapsFolder = game.ReplicatedStorage.Maps
local LobbySpawn = game.Workspace.Spawn
--[[
local function ToMinutesAndSeconds(seconds)
return Format(math.floor(seconds / 60))..":"..Format(seconds % 60)
end
]]
InRound.Changed:Connect(function()
if InRound.Value == true then
local mapChildren = MapsFolder:GetChildren()
local chosenMap = mapChildren[math.random(1,#mapChildren)]
clonedMap = chosenMap:Clone()
clonedMap.Parent = game.Workspace.WorkspaceMaps
for _, player in pairs(game.Players:GetPlayers()) do
local char = player.Character
char.HumanoidRootPart.CFrame = clonedMap.Spawn.CFrame
end
else
for _, player in pairs(game.Players:GetPlayers()) do
local char = player.Character
char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
end
clonedMap:Destroy()
end
end)
function Format(Int)
return string.format("%02i", Int)
end
function convertToMS(Seconds)
local Minutes = (Seconds - Seconds%60)/60
Seconds = Seconds - Minutes*60
return Format(Minutes)..":"..Format(Seconds)
end
local function startRoundTimer()
while wait() do
for i = intermissionLength,1,-1 do
InRound.Value = false
Status.Value = "Intermission: "..convertToMS(i).." until a new round."
task.wait(1)
end
for i = roundLength,1,-1 do
InRound.Value = true
if #workspace.WorkspaceMaps:GetChildren() > 0 then
Status.Value = "Ingame: "..convertToMS(i).." until round is over. Map Chosen: "..workspace.WorkspaceMaps:GetChildren()[1].Name
else
Status.Value = "Ingame: "..convertToMS(i).." until round is over."
end
task.wait(1)
end
end
end
task.spawn(startRoundTimer)
Thank you again for looking.