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

How to set all decals with a name?

Asked by 4 years ago
for i,child in pairs(parent:GetChildren()) do
    if child:IsA('Decal') and child.Name == 'Science' then
        child.Texture = "http://www.roblox.com/asset/?id=3916138491"-- or Child.Locked = true
    end
end

i am trying to make it when the game starts any decals with the name Science it will change there texture to this http://www.roblox.com/asset/?id=3916138491

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Your code is perfect! You just needed to add "script" into the first line, shown here:

for i, child in pairs(parent:GetChildren()) do

to

for i, child in pairs(script.Parent:GetChildren()) do

for i, child in pairs(script.Parent:GetChildren()) do -- Going through the children
    if child:IsA('Decal') and child.Name == 'Science' then -- Is it a decal? Is it's name "Science"?
        child.Texture = "http://www.roblox.com/asset/?id=3916138491" -- Let's change it!
    end
end
Ad
Log in to vote
0
Answered by 4 years ago

Thanks

Answer this question