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

Two lined search?

Asked by 10 years ago

So I have been scripting quite a while now when I came across a problem, I cannot access a two lined name. Such as a weapon named Redcliff Sword. How would you access that simply like using

game.StarterPack.Redcliff Sword:clone()

Any help?

2 answers

Log in to vote
3
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

It's very simple.

game.StarterPack["Redcliff Sword"]:Clone() --Notice the lack of a period after 'StarterPack'

Or, alternatively, if you're not certain it exists:

game.StarterPack:FindFirstChild("Redcliff Sword"):Clone()
1
Wait could I keep oing with that by doing: game.StarterPack["Redcliff Sword"].Script:Destroy() Do I need a period after ] or no? SiIentSins 0 — 10y
0
That line is correct. You can use this method wherever you would use a period: Workspace["Object 1"]["Child 6"].Period["Stoof Bloof"]:Clone().Parent = Workspace adark 5487 — 10y
1
I wish I could rate twice or more, because this is an excellent answer... fahmisack123 385 — 10y
1
I think it's always good to remind askers of the syntactic sugar behind `.`. A.B is doing behind the scenes A["B"]! BlueTaslem 18071 — 10y
0
I was not aware that was syntactic sugar! Sometimes even the knowledgable learn. adark 5487 — 10y
Ad
Log in to vote
-1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
s = game.StarterPack["Redcliff Sword"]:clone()
s.Parent = --Wherever you want to put it.

Answer this question