Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is it possible to use concatenations in hierarchies?[CLOSED]

Asked by 10 years ago

I've toyed around with this before, but I don't think I ever got it to work. I just want to know if something like this is possible, and if so how to go about doing it.

Say I have 10 parts in Workspace named part1, part2, part3 and so on. Is it possible to use something like the following code to reference one of the parts?

game.Players.PlayerAdded:connect(function()
    random = math.random(1, 10)
    Workspace[part..random]:Destroy()
end)

edited for spelling

1 answer

Log in to vote
1
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

As long as 'part' is a variable, otherwise you need to make it a string.

Ad

Answer this question