Hi, I have a script which I use where whenever the parent is touched, it makes all children visible. I've looked at GetChildren() and and GetDescendants() but they're read-only, and I need to be able to make the children transparent. Any help?
This is simple, you only need to use an In Pairs
loop and call GetChildren()
/GetDescendants
instead of a table, your script will automatically make all children visible, something like this:
GetChildren()
example:
for i, v in pairs(Parent:GetChildren()) do --Your script, "v" would be the instance your making visible end
GetDescendants()
example:
for i, v in pairs(Parent:GetDescendants()) do --Your script end
Hope you know what an In Pairs loop is, if not watch this AlvinBlox video, he explains it pretty well
Hello.
Im not sure what exactly your going for but this should work. reply if it doesnt. i maybe able to help again.
You probably want to use a loop. more specifically an in pairs loop this should do the trick:
local transparency = 0 -- 0 will make it visible while 1 will make it invisible local part = game.Workspace.Part -- change this to the part that will be touched part.Touched:Connect(function(hit) -- we put hit there incase we ever need the player in the future for i,v in pairs(part:GetChildren()) -- loop through all the children v.Transparency = transparency -- change the childrens transparency end end)
There may be typos/capitalization errors. i didnt use roblox studio to write this