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

brick color changing GUI not working?

rn i am trying to make a gui that when clicked changes the color of a part. this is the script i have right now

script.Parent.MouseButton1Click:Connect(function(player)
	game.Workspace.ColorPart.BrickColor = Color3.new(0, 0, 0)
end)

but my output just says:

20:01:19.421 - Players.mynam3with123.PlayerGui.ScreenGui.TextButton.LocalScript:2: invalid argument #3 (BrickColor expected, got Color3)

1 comment

1

Conflicting datatypes, you need to supply a BrickColor Object. You can construct a new one like so: BrickColor.new(string BrickColor)

1 answer

✓ Accepted answer

As Feahren already explained perfectly in their comment, you are supplying an invalid datatype to the property you are trying to change.

A part's BrickColor requires BrickColor.new(number val)

However, if you would like to get away from using a BrickColor datatype (I know I do), then you could simply take advantage of the fact that most part objects now have a Color property that can be supplied a Color3 datatype!

Therefore, your new code could look like this!

local GUI_Object = script.Parent
local ColorPart = game.Workspace.ColorPart

GUI_Object.MouseButton1Click:Connect(function(player)
    ColorPart.Color = Color3.new(0, 0, 0)
end)

I hope this helps!

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