The Status Board
Lesson 2 of 18 in Coddy's Roblox Game: Disaster Survival course.
Players in the lobby need to know what happens next. The big dark part there, workspace.StatusBoard, will show it.
Text on a part is a SurfaceGui holding GUI objects such as a TextLabel. A SurfaceGui inside a part draws on one face, the Front face unless you change its Face. The board has been turned so its Front faces the lobby.
local gui = Instance.new("SurfaceGui")
gui.Parent = workspace.Sign
local label = Instance.new("TextLabel")
label.Size = UDim2.fromScale(1, 1)
label.Text = "Hello!"
label.TextScaled = true
label.Parent = guiA GUI size is a UDim2: a fraction of the parent (Scale) plus pixels (Offset) on each axis. UDim2.fromScale(1, 1) is the whole parent, so the label covers the board. TextScaled makes the text as large as fits.
Challenge
EasyBelow the PlayerAdded code, put a status label on the board:
- A SurfaceGui parented to
workspace.StatusBoard. - A TextLabel named
Statusin it, the size of the board (UDim2.fromScale(1, 1)). - A dark background (
Color3.fromRGB(25, 25, 35)), white text (Color3.fromRGB(255, 255, 255)) withTextScaledon, readingWelcome to Disaster Survival!
Press Play and look at the board, then Check.
Try it yourself
local Players = game:GetService("Players")
local Settings = require(game.ReplicatedStorage.Settings)
print("Rounds last " .. Settings.RoundLength .. " seconds")
-- Every player gets Wins on the leaderboard
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local wins = Instance.new("IntValue")
wins.Name = "Wins"
wins.Parent = leaderstats
end)
This lesson includes a short quiz. Start the lesson to answer it and track your progress.