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

Is there any way to change a property of a part inside a two word model?

Asked by 6 years ago
Edited 6 years ago

How exactly can i do this?

I want to change the transparency of something inside a two word model, but I'm not sure how to

script.Parent.Touched:connect(function(hit)
       script.Parent.Parent.Parent.(idk).Head.Transparency = 0
                                    ^^^^
                                   Thats where the model is
end)

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

In my opinion, the best way to identify two word models is with FindFirstChild, because the child you are identifying is always in quotation marks. Using this technique, you can identify models with as many words as you want, though I would try to keep it reasonable. Another option would be to use brackets, which you can also put quotation marks into. Again, you can use this with as many words as you want. Both of these methods will work the same way. It is up to you to decide which one is best for your game. Good luck! Here is your example, modified both ways:

Option 1:

script.Parent.Touched:connect(function(Hit)
script.Parent.Parent.Parent["Multiple Word Model"].Head.Transparency = 0
end)

Option 2:

script.Parent.Touched:connect(function(Hit)
script.Parent.Parent.Parent:FindFirstChild("Multiple Word Model").Head.Transparency = 0
end)
0
Oh, I didn't know that. Thank you so much! ProjectJager 62 — 6y
0
Be sure to accept an answer if it helped you. I would really appreciate it. :) ThatPreston 354 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Instead of using the '.' operator, you will make use of "[]" one instead. For example, let's say your model is named "My Model", then your code will become the following:

script.Parent.Touched:connect(function(hit)
       script.Parent.Parent.Parent["My Model"].Head.Transparency = 0
end)

Answer this question