Overview
Hello, in this tutorial I will be teaching you the basics of making a Time-Trial Game, Time-Trial Games are basically obby games with a speedrunning aspect added to them, the goal is to finish an obby in the fastest time possible, so we will replicate that today. Here are some examples of Time-Trial games that have been popularized, the RBXL of today’s tutorial, and all of the Roblox API links you can click on to learn more about the topic:
Time Trial Game Examples
- Time Tactic
- Amir’s Time Trial
- Time Test
- Test Your Time!
RBXL File
TimeTrialPart1.rbxl (34.0 KB)
Roblox API's Of Things You Should Study
The Setup
Step 1: Make a simple obby with a START and END block in studio (obviously it can be more detailed but for this tutorial, it won’t be)
Step 2:
Name your Start/End blocks, and organize everything into a folder:
Step 3:
We’re gonna add a ScreenGui in StarterGui, then a frame in it, and a text label in that frame, then add a “UI Corner” into the TextLabel and Frame, and color them however you like, remember to go into the properties of your text, change the font if you want and check the bool “TextScaled” for a better look it should look a little like this once you finish those steps:
Step 4:
Add a script into the Start and End parts, then a Local-Script into the TextLabel Gui and a script into ServerScriptService, with a BoolValue inside of the script, then another script in ServerScriptService:
The Scripting
Alright, we’re gonna get into the fun part, scripting!
In this tutorial, we won’t be doing that much, but in the next couple of tutorials more will come:
In the start script, we need this, it sets the Bool to true when you step on it:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
local BoolVal = Player:WaitForChild("BoolStartEnd")
BoolVal.Value = true
end
end)
In the end script, we need this, it sets the Bool to false when you step on it:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local Player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
local BoolVal = Player:WaitForChild("BoolStartEnd")
BoolVal.Value = false
end
end)
Next, in our “BoolDiedScript”, in ServerScriptService we need to make the timer end once you die (or it would be really weird):
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function(died)
local Bool = player:WaitForChild("BoolStartEnd")
local TimerText = player:WaitForChild("PlayerGui").TimerGui.Frame.Timer
Bool.Value = false
TimerText.TextColor3 = Color3.fromRGB(255, 0, 4)
player:Connect(function()
TimerText.TextColor3 = Color3.fromRGB(50, 50, 50)
end)
end)
end)
end)
In our local-script under timer-text were gonna have this, this is the actual script for the timer, it will be modified in future tutorials:
local PlayerGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
local Timer = PlayerGui:WaitForChild("TimerGui").Frame.Timer
local BoolVal = game:GetService("Players").LocalPlayer:WaitForChild("BoolStartEnd")
local Time = 0
while wait() do
if BoolVal.Value == true then
Timer.TextColor3 = Color3.fromRGB(50,50,50)
Timer.Visible = true
Timer.Text = Time.."s"
wait(0.1)
Time = Time + 0.1
elseif BoolVal.Value == false then
Timer.TextColor3 = Color3.fromRGB(0, 255, 0)
Time = 0
end
end
In the BoolValue-Script under ServerScriptService (the one with a bool inside it) were gonna have this script that basically clones that BoolValue INTO the player:
game:GetService("Players").PlayerAdded:Connect(function(player)
script:WaitForChild("BoolStartEnd"):Clone().Parent = player
end)
Final Result
Here’s how it all came out, not the best because this is just part 1, but I will make lots more parts hopefully
The End
Although this is a very simple script and definitely needs improvement, it should be a starting place for this series.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
0 voters