Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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.

0
why so many spaces? did you delete code? awesomeipod 607 — 6y
0
no its just like that lol I was gonna tidy it up later carsheep -8 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
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.

0
When I add the rest of the code it only displays on one again carsheep -8 — 6y
0
as in changing the texture on all of them carsheep -8 — 6y
0
it seems a wait time in between switching textures is breaking it carsheep -8 — 6y
0
err sweetkid01 176 — 6y
View all comments (3 more)
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" User#19524 175 — 6y
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 carsheep -8 — 6y
0
it's like going in order on all of the parts and not all at once carsheep -8 — 6y
Ad

Answer this question