Paul
Paul

Reputation: 1327

Create a textLabel in Roblox using only code

As the title indicates, I am looking at creating a label for a player Gui in Roblox using only code. Under the folder StarterGui, I have a ScreenGui, and as a child of ScreenGui I have a local script with the following code:

local ScreenGui = script.Parent
local label = Instance.new("TextLabel", ScreenGui)
label.Size = UDim2.new({0, 200},{0, 100})
label.Text = "label"
label.TextColor3 = Color3.new (0,0,0)
label.TextSize = 36
label.Font =  "Arial"
label.TextScaled = true

I am pretty sure I should be seeing a label with the word ''label'' by now, but nothing. What am I missing?

Upvotes: 1

Views: 1335

Answers (1)

Wyatt
Wyatt

Reputation: 46

The line that says label.Size = UDim2.new({0, 200},{0, 100})

Should be label.Size = UDim2.new(0, 200, 0, 100)

This is because UDim2.new accepts 4 arguments, not 2 arrays.

Hope I could help!

Upvotes: 3

Related Questions