So I have this script which is supposed to reproduce a sort of flashing neon, the script functions because in the output in prints 'Script Works' after every loop. However, my problem is that the color and the material of the brick don't change at all, they stay the exact same.
local material = script.Parent.Material local color = script.Parent.BrickColor function change_mat() material = Enum.Material.Neon wait(1) material = Enum.Material.Plastic wait(5) material = Enum.Material.Neon wait(.5) material = Enum.Material.Plastic end color = 'Red' while true do change_mat() wait(1) print('Script Works') end
First, for the part to change your color of brick.
When you want to change the colors of brick using BrickColor, you always have to use the BrickColor.new() to do it. Also, the brick color "Red" does not exist in Roblox apparently, so try to look for the right name by going to your part > BrickColor, then hover over the color you want to use for the right name. example :
local color = script.Parent.BrickColor color = BrickColor.new("Lime green")
Now onto material of brick. As far as I know, you have to define the material like :
local part = script.Parent part.Material = Enum.Material.Neon
instead of making a variable
material = part.Material
which won`t work.
First assign the part you will be changing to a variable, rather than the part's properties
Like so,
local Part = script.Parent
Since you said you wanted the part to flash, I would suggest taking out the long wait and replacing it with just one
(Btw, since this function is in a while loop, it will continuously loop, so you don't have to constantly change the parts material from neon to plastic, just once will do. :D
function change_mat() Part.Material = Enum.Material.Neon wait(0.5) Part.Material= Enum.Material.Plastic end
if you want to change the color of the brick to Red, you should set color equal to
Brickcolor.new("Really Red")
-- (That's the name in roblox for Red, but you have various different shades, just look up Roblox Colors Names)
lastly connect it all in a while loop:
while true do change_mat() wait(1) print('Script Works') end
Hopefully this helps!