Hello! I am trying to make a script in which i change multiple brick colors of multiple parts that all contain a tag. This seems pretty simple to me but for some reason which i cannot pin-point, the loop does not change any brickcolors but does still run as the print statements still run as usual. This confuses me a lot, why does the brickcolor not change anymore but the print statements do run? please help if you know
code (inside of a local script in startercharacterscripts):
for _,v in pairs(game:GetService("CollectionService"):GetTagged("jimbob")) do
-- local Beam = v:WaitForChild("Decal")
task.spawn(function()
while wait() do
v.BrickColor=BrickColor.new("Really red")
print(0)
task.wait(2)
v.BrickColor=BrickColor.new("Cyan")
print(1)
task.wait(2)
end
end)
end
local CollectionService = game:GetService("CollectionService")
while true do
for _,v in CollectionService:GetTagged("jimbob") do
v.BrickColor=BrickColor.new("Really red")
end
task.wait(2)
for _,v in CollectionService:GetTagged("jimbob") do
v.BrickColor=BrickColor.new("Cyan")
end
task.wait(2)
end
wow! This actually ended up working perfectly with just a copy and paste, thank you! I’m curious though, what is the big difference which made this one work compared to the last one? once again, thank you!
ahh i see, so the while loop has to be outside of the for loop, that actually makes a lot of sense, i hadn’t thought of that. and it also being roblox is also nice to know :') thank you so much this was a great thing to learn and i was able to fix my problem with your help, thank you and have a good day/night/ anythign!!