Hello i made a script that should hide the part when a value is enabled
Script :
local V = script.Parent.Value local Model = script.Parent.Parent.Parent local Object = { Model["Head"], Model["Torso"], Model["Left Arm"], Model["Left Leg"], Model["Right Arm"], Model["Right Leg"] } if V == true then Object.Locked = true Object.Transpency = 1 Object.Anchored = true 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:
local V = script.Parent.Value local Model = script.Parent.Parent.Parent local Object = { Model["Head"], Model["Torso"], Model["Left Arm"], Model["Left Leg"], Model["Right Arm"], Model["Right Leg"] } V.Changed:Connect(function(prop) -- Every time the value changes, this will check if it is true if V == true then for i = 1, #Object, 1 do Object[i].Locked = true Object[i].Anchored = true Object[i].Transparency = 1 end end end)
If it were me, I would do a much simpler version of what you're doing. It would look like this:
local V = script.Parent.Value local Model = script.Parent.Parent.Parent V.Changed:Connect(function(prop) -- Every time the value changes, this will check if it is true if V.Value == true then for Index, Descendant in pairs(Model:GetChildren()) do -- Gets all children of model -- Line below this one checks if the Descendants should be "hidden" 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 Descendant.Locked = true Descendant.Transparency = 1 Descendant.Anchored = true end end end end)