I have constructed a script that lets you change the color of a part on your model, but when I click it, it only colors one part. What I am aiming for is to click this button and for all parts named "Wing1" to be colored.
local wings1 = game:GetService("ReplicatedStorage").Recolor.Wings1:WaitForChild("a") wings1.OnServerEvent:Connect(function(player,part) local model = player.Character:FindFirstChildOfClass("Model") model.Wings.Wing1.Color = Color3.fromRGB(255, 255, 255) end)
There are several separate parts named "Wing1" underneath the "Wings" model, and this script is only coloring one of them. How do I color all of them?
EDIT: Another method I tried is:
local wings1 = game:GetService("ReplicatedStorage").Recolor.Wings1:WaitForChild("a") wings1.OnServerEvent:Connect(function(player,part) local Bird = player.Character:FindFirstChildOfClass("Model") Bird.Wings:GetChildren("Wing1").Color = Color3.fromRGB(255, 255, 255) end)
But this makes the script not work entirely.
Well, I'm not sure this is the best strategy but, you can try using a for loop and color all the wings like that. Example:
local wings1 = game:GetService("ReplicatedStorage").Recolor.Wings1:WaitForChild("a") wings1.OnServerEvent:Connect(function(player,part) local model = player.Character:FindFirstChildOfClass("Model") for i,v in pairs(model:GetChildren()) do if v.Name = "Wing1" then v.Color = Color3.fromRGB(255, 255, 255) end end end)
This should work. Again, this might not be the best method, but it should work.
If this helped, please accept the answer. Thanks!
Write the main code inside the module script and insert a server script on every brick. Just add calling Module script Lines.
Works perfectly.