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

How would you use GetChildren() to change decals in lots of parts?

script.parent.SafetyOn.OnServerEvent:connect(function()
for i,v in pairs(script.parent.parent.parent.IFE:GetChildren()) do


v.Decal.Transparency = 1
    v.Slidetwo.Transparency = 1
    
    
    
    
    
    v.Main.Transparency = 1
    
    
    v.Slideone.Transparency = 1
    
            
                v.Security.Transparency = 0

The issue im having with this is that its only changing one of the parts and not all.

2 comments

0

why so many spaces? did you delete code?

0

no its just like that lol I was gonna tidy it up later

1 answer

script.parent.SafetyOn.OnServerEvent:connect(function()
	for i,v in pairs(script.parent.parent.parent.IFE:GetDescendants()) do -- you'll want :GetDescendants()
		if v:IsA("Decal") and v.Name ~= "Security" then -- if izza decal and not named "Security"
			v.Transparency = 1 -- poof
		elseif v:IsA("Decal") and v.Name == "Security" then -- if izza decal named "Security"
			v.Transparency = 0 -- o hai decal
		end
	end
end)

Should do the trick.

7 comments

0

When I add the rest of the code it only displays on one again

0

as in changing the texture on all of them

0

it seems a wait time in between switching textures is breaking it

0

err

0

Don't say :IsA("Decal") because the "Texture" class inherits from Decal and if he has Textures in there they could get affected. Like if you said :IsA("Part") on some script and you had spawnlocations or seats those get affected since they inherit from Part. Consider inheritance and say if v.ClassName == "Decal"

0

Im still having the same issue, Only one of the decals turns visible then after the wait time the other part starts. But what I need is for them to all run in sync together

0

it's like going in order on all of the parts and not all at once

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