So I have a script that changes the parts to neon if they aren't (sorta broken as is) I was wonder, how can I only change the parts with the name "Colorfull"
function onClicked() local GetBoat = game.Players.LocalPlayer.Character local colorfulls = GetBoat.NormalBoat:GetChildren("Colorfull") local boot = GetBoat.NormalBoat if boot.Colorfull.Material == "Neon" then print("If2done") for i = 1, #colorfulls do colorfulls[i].Material = "Plastic" end script.Parent.booton.TextColor3 = Color3.new(255,255,255) else for i = 1, #colorfulls do colorfulls[i].Material = "Neon" end script.Parent.booton.TextColor3 = Color3.new(255,0,0) end end script.Parent.booton.MouseButton1Click:connect(onClicked)
Use the Pairs function, and the GetChildren()
method is a read only table of the parent's children.
local colorFull = GetBoat.NormalBoat:GetChildren() for i,v in pairs(colorFull) do -- the i,v and be renamed f.y.i -- settings end
function onClicked() local GetBoat = game.Players.LocalPlayer.Character local colorfulls = GetBoat.NormalBoat:GetChildren() local boot = GetBoat.NormalBoat for i,v in pairs(colorfulls) do if v.Name=="NamHere" then print("If2done") for i = 1, #colorfulls do colorfulls[i].Material = "Plastic" end else script.Parent.booton.TextColor3 = Color3.new(255,255,255) for i = 1, #colorfulls do colorfulls[i].Material = "Neon" end script.Parent.booton.TextColor3 = Color3.new(255,0,0) end end end script.Parent.booton.MouseButton1Click:connect(onClicked)