I want to make a brick change all it's RGB values by 1 every 10 miliseconds and then loop back to 0 (+ the overclocked numbers)
I don't have a starting script yet so i hope you understand what i need help with :|
This script could help you
local part = script.Parent -- The part you want it to change color local a = 0 while true do --loop repeat --repeat a = a -1 part.Color = Color3.new(a,a,a) wait(0.1) until a == 255 --Repeat untill the part is white a=0 -- set back to 0 part.Color = Color3.new(0,0,0) -- Set the part back to black wait(1) -- The delay end
I know it's annoying to say such, but you should at least have tried to start a loop or something, having to do an entire script makes it a request, and this isn't what this website is about. but anyways, hope this helps.
Brick = script.Parent -- Gets your brick if the script is it's parent Color = 0 Debounce = false function ChangeColor() while true do -- loops the other loops while Color < 255 and not Debounce do Color = Color + 1 Brick.Color = Color3.fromRGB(Color,Color,Color) print(Color) wait(0.01) end Debounce = true while Color > 0 and Debounce do Color = Color - 1 Brick.Color = Color3.fromRGB(Color,Color,Color) print(Color) wait(0.01) end Debounce = false wait() end end ChangeColor() -- Calls the function
I wasn't really able to formulate comments that would fit, so basically it calls a function that loops two other loops. The first one checks if the Color is below 255 and the Debounce is off, making the brick go from 0,0,0 to 255,255,255 if so. the other one checks if it's above 0 and if the Debounce is on, causing the same effect but inverted if so. The purpose of the Debounce is so that they don't end up acting out of order and glitching the effect. It will loop forever unless the script is deactivated. Since I only used one variable ( Color
), this will only allow the black and white effect you asked, if you need the other values you can create a table, and edit the Color3
like this:
Color = { 0, 0, 0, } Brick.Color = Color3.fromRGB(Color[1],Color[2],Color[3])