A small question

Can anyone tell why “[ ]” (aka square brackets) is used? I know it’s mostly used in arrays but I have seen scripts where these square brackets are used after variables… Can anyone explain?

Can you elaborate further.
Can you send me a example?

local player = game:GetService(“Players”).LocalPlayer
local part = workspace.BuyStages.ObbyPart1
local cash = player:WaitForChild(“leaderstats”):WaitForChild(“Cash”)
local Stage1 = game.Workspace[“Stage 1”]

while true do
part.Touched:Connect(function(hit)
if hit.Parent == player.Character then
if cash >= 100 then
Stage1.Visible = true
Stage1.CanColide = true
end
end
end)
end

I got this script from another guy from scripting support category… and check line 4 that’s where I got doubt…
That Stage1 variable.

I wonder if it is used to get a child??

In that situation, the brackets are being used because there is a space in the name of “Stage 1”. If you did workspace.Stage 1, it would error because it saw “Stage” and “1” as seperate things.

So you mean it is also used to get children in strings???

Let’s say we have a basket

local basket = {"Orange", "Apple"}

But you want to bring apple.
Apple at second in table.

basket[2]

this is Apple!

Yup, if you wanted to get a child, you could do

workspace.RandomFolder

Or

workspace[“RandomFolder”]

local table = {"String",1,true}
print(table[1])

Output: String

local table = {"String",1,true}
print(table[2])

Output: 1

local table = {"String",1,true}
print(table[3])

Output: true

Yep I know how that work… I was just asking if we can get a child for eg. Workspace[“Model”]

Well thanks Devs I got it now.