iOSdeveloper

Untitled

Jan 15th, 2025
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. local segmentSystem = workspace:FindFirstChild("segmentSystem")
  2. if not segmentSystem then
  3. warn("segmentSystem not found in workspace.")
  4. return
  5. end
  6.  
  7. local segments = segmentSystem:FindFirstChild("Segments")
  8. if not segments then
  9. warn("Segments not found in segmentSystem.")
  10. return
  11. end
  12.  
  13. -- Counter for segments with changed colors
  14. local changedSegmentCount = 0
  15.  
  16. -- Iterate through each segment
  17. for _, segment in ipairs(segments:GetChildren()) do
  18. if segment:IsA("Model") then -- Ensure it's a model
  19. local folder = segment:FindFirstChild("Folder")
  20. if folder then
  21. -- Get all children in the folder
  22. local parts = folder:GetChildren()
  23. local segmentChanged = false -- Track if any part in this segment was changed
  24. for _, part in ipairs(parts) do
  25. if part:IsA("Part") and part:FindFirstChild("breakable") then
  26. -- Check if the breakable property is true
  27. if part.breakable.Value == true then
  28. -- Change the color to yellow
  29. part.BrickColor = BrickColor.new("Bright yellow")
  30. segmentChanged = true -- Mark that this segment has changed
  31. end
  32. end
  33. end
  34. -- If any part in this segment was changed, increment the counter
  35. if segmentChanged then
  36. changedSegmentCount = changedSegmentCount + 1
  37. end
  38. end
  39. end
  40. end
  41.  
  42. -- Print the total number of segments that had their parts changed
  43. print("Total segments with changed colors: " .. changedSegmentCount)
  44. end)
Advertisement
Add Comment
Please, Sign In to add comment