Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

my color changing script will not work??

I am making a script that will, when the surface gui button is clicked, changes the color of the brick to red, and makes it neon, but it will not work. here is the script :

TextButton.MouseButton1Click:connect(function() script.Parent.Parent.Light1.BrickColor = BrickColor.new("Really red") wait(0.1) script.Parent.Parent.Light1.Material = Material.new("Neon") end)

If you could tell me what I'm doing wrong, i would be really happy to find out.

4 comments

0

“Material.new” doesn’t exist I think, and is the SurfaceGui parented to StarterGui/PlayerGui and does it have an adornee set in its properties?

0

Also, it would be helpful if you could turn the code you are attempting to show us into a code block, so it is easier to read.

0

^ The button won’t work if it’s parented in a part. You’ll have to put it in StarterGui and set the adornee to the part. The button should then work, except now you’ll have to use remote events. :P

1 answer

First issue I see is "Material.new()" this does not exist. You can do it instead in one of two ways: Material = "MaterialType" or Material = Enum.Material.MaterialType. This script should work:

TextButton.MouseButton1Click:connect(function() 
script.Parent.Parent.Light1.BrickColor = BrickColor.new("Really red") 
wait(0.1) 
script.Parent.Parent.Light1.Material = Enum.Material.Neon
end)

1 comment

0

No, using strings is not cool.

This discussion is preserved as it was. New answers, comments, and votes are closed.