Error when using BackgroundColor3

For a little background, I have decided to change a shop system that previously appeared when you spawn in and respawn, to having a click detector activated script that I can use so a player can open it. After converting a lot of things, I can’t get past this error.

image

	if cameras:FindFirstChild("Camera"..current_camera).Toolname.Value == "Dagger" and plr.Backpack:FindFirstChild("Dagger") then
	print(cameras:FindFirstChild("Camera"..current_camera).Toolname.Value)
	EQUIP_BUTTON = "EQUIPPED BY DEFAULT"
	EQUIP_BUTTON.BackgroundColor3 = Color3.new(255/255, 0/255, 0/255)
end

Above is line 37 and the if statement around it. It is in a local function inside of the click detecting function.

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
local EQUIP_BUTTON = plr.PlayerGui.MainGui.Equip

For a little more context, here is the function that runs everything, and this is how my equip button has been defined. Basically, the dagger gets equipped by default if nothing else does. I have no idea why it can’t identify BackgroundColor3, but if anyone has a solution, please let me know. This is in a server script.

I think you made a typo in your code:

EQUIP_BUTTON = "EQUIPPED BY DEFAULT" --in this line your setting the button to a string
--I think you mean this:
EQUIP_BUTTON.Text = "EQUIPPED BY DEFAULT"

The error is happening because your replacing the button with a string, hence the error.

2 Likes