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

How to use local/global variables in a hierarchy string?[FIXED]

Asked by 9 years ago

I am making a script, to find a certain object it needs to use a global variable in it (plyr)! How can I get it to use that variable? Here is that part of my script

print("loading")
plyr = script.Parent.Parent.Parent.Name
print(plyr)
char = workspace.plyr --this little guy!
anim = char.Humanoid:LoadAnimation(animation)

Fixed

print("loading")
plyr = script.Parent.Parent.Parent.Name
print(plyr)
char = workspace[plyr] --this little guy!
anim = char.Humanoid:LoadAnimation(animation)

Please help!!! Thank you!!!

0
you could easily find the character by writing "script.Parent.Parent.Parent.Character" if "plyr" is set to the value of the player's Name property. ImageLabel 1541 — 9y

1 answer

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

You're looking for an object with the name "plyr" and not the object with the name of the value of the variable plyr. Instead, write char=workspace:FindFirstChild(plyr)

Ad

Answer this question