Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

0

Oh, I didn't know that. Thank you so much!

0

Be sure to accept an answer if it helped you. I would really appreciate it. :)

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.