How do i script a 'timed obby'?

Hey so please be aware i am fairly new to scripting andi would like to know how i make a obby like flood escape where you have to complete a obby in a set amount of time as im not entirely sure.

Thanks in advance!

I’ll script an example real quick and you can use that. I’ll get back to you soon.

2 Likes

I’ve come up with a list of things you’d have to include in order to make a timed game:

  1. Create a timer. Players should be able to see this on their screen so they know how much time they have left.

  2. Build the obby. This includes stages, spawns, checkpoints, etc.

  3. Use a script to detect when the timer has reached 0. When it has, just teleport players back to the original spawn point (the start of the obby). You would then reset the timer and repeat the process again.

Again, this is a simple outline of the basis of a timed game. If you would like a deeper explanation on any of the steps or small code samples, feel free to let me know.

3 Likes

I’ve written this all for you to use as a example.
If you don’t understanding anything I recommend looking into each thing.
Feel free to check my answer if you think its a solution.
If there’s any errors please say so.
-Thanks Alpha

--Server Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateStatusRemote = ReplicatedStorage:WaitForChild("UpdateStatusRemote")

local IntermissionTime = 30
local RoundTime = 300
local SpawnPart = game.Workspace:WaitForChild("SpawnPart") --Where player spawns
local StartPart = game.Workspace:WaitForChild("StartPart") --Where player spawns at the stat of obby
local WinPart = game.Workspace:WaitForChild("WinPart") --Where player needs to get

while true do
	UpdateStatusRemote:FireServer("Intermission")
	wait(IntermissionTime)
	for i, Player in pairs(game.Players:GetChildren()) do
		local Character = game.Workspace:WaitForChild(Player.Name)
		Character.HumanoidRootPart.Position = StartPart.Position
	end
	UpdateStatusRemote:FireAllClients("StartRound", RoundTime)
	wait(RoundTime)
	local Winners = {}
	local WinRegion1 = Vector3.new(WinPart.Position.X - WinPart.Size.X/2, 0, WinPart.Position.Z - WinPart.Size.Z/2)
	local WinRegion2 = Vector3.new(WinPart.Position.Z - WinPart.Size.Z/2, 20, WinPart.Position.Z - WinPart.Size.Z/2)
	local WinRegion3 = Region3.new(WinRegion1, WinRegion2)
	local Region3Parts = game.Workspace:FindPartsInRegion3(WinRegion3, 100)
	for i, Region3Part in pairs(Region3Parts) do
		if Region3Part.Parent:FindFirstChild("Humanoid") then
			local InTable = false
			for i, Player in pairs(Winners) do
				if Region3Part.Parent.Name == Player.Name then
					InTable = true
					break
				end
			end
			if InTable == false then
				table.insert(Winners, game.Players[Region3Part.Parent.Name])
			end
		end
	end
	--Your winners are the "Winners" table.
	for i, Player in pairs(game.Players:GetChildren()) do
		local Character = game.Workspace:WaitForChild(Player.Name)
		Character.HumanoidRootPart.Position = SpawnPart.Position
	end
end

--Local Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateStatusRemote = ReplicatedStorage:WaitForChild("UpdateStatusRemote")
local TimeText = script.Parent

UpdateStatusRemote.OnClientEvent:Connect(function(Status, Time)
	if Status == "StartRound" then
		TimeText.Text = Time
		for i = 1, Time do
			TimeText.Text = tonumber(TimeText.Text) - 1
		end
	elseif Status == "Intermission" then
		TimeText.Text = "Intermission"
	end
end)
2 Likes

Try using the TweenService to make the water rise.

1 Like