Hello i made a script that should hide the part when a value is enabled
Script :
01 | local V = script.Parent.Value |
02 | local Model = script.Parent.Parent.Parent |
03 |
04 | local Object = { |
05 | Model [ "Head" ] , |
06 | Model [ "Torso" ] , |
07 | Model [ "Left Arm" ] , |
08 | Model [ "Left Leg" ] , |
09 | Model [ "Right Arm" ] , |
10 | Model [ "Right Leg" ] |
11 | } |
12 |
13 | if V = = true then |
14 | Object.Locked = true |
15 | Object.Transpency = 1 |
16 | Object.Anchored = true |
17 | end |
I think there is a problem with the "Object" value.
I hope you understand.
Thanks.
One reason your didn't work was becasuse your Object table was called, but you didn't say list any index that that you wanted. Another way to do your script, if you really wanted it to be a table is like this:
01 | local V = script.Parent.Value |
02 | local Model = script.Parent.Parent.Parent |
03 | local Object = { |
04 | Model [ "Head" ] , |
05 | Model [ "Torso" ] , |
06 | Model [ "Left Arm" ] , |
07 | Model [ "Left Leg" ] , |
08 | Model [ "Right Arm" ] , |
09 | Model [ "Right Leg" ] |
10 | } |
11 |
12 | V.Changed:Connect( function (prop) -- Every time the value changes, this will check if it is true |
13 | if V = = true then |
14 | for i = 1 , #Object, 1 do |
15 | Object [ i ] .Locked = true |
16 | Object [ i ] .Anchored = true |
17 | Object [ i ] .Transparency = 1 |
18 | end |
19 | end |
20 | end ) |
If it were me, I would do a much simpler version of what you're doing. It would look like this:
01 | local V = script.Parent.Value |
02 | local Model = script.Parent.Parent.Parent |
03 |
04 | V.Changed:Connect( function (prop) -- Every time the value changes, this will check if it is true |
05 | if V.Value = = true then |
06 | for Index, Descendant in pairs (Model:GetChildren()) do -- Gets all children of model |
07 | -- Line below this one checks if the Descendants should be "hidden" |
08 | if Descendant.Name = = "Head" or Descendant.Name = = "Torso" or Descendant.Name = = "Left Arm" or Descendant.Name = = "Left Leg" or Descendant.Name = = "Right Arm" or Descendant.Name = = "Right Leg" then |
09 | Descendant.Locked = true |
10 | Descendant.Transparency = 1 |
11 | Descendant.Anchored = true |
12 | end |
13 | end |
14 | end |
15 | end ) |