How can I fix these red underlines in my code, and fix the errors?

Hi,
In my script, there are red underlines under certain parts of my code.

Why is that? How can I fix this script so it has no errors? What am I doing wrong?
(By the way, this is a local script.)
image

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid")then
		if game.Workspace.FactoryLasers.LaserButton.BrickColor = (255, 0, 0) then
			then
		game.Workspace.NoLazerBadge.BadgeAwarderScript.Disabled = false
		end
	end)

(And also, the brick color’s name is “Really red”.)

1 Like

You need to remove the bracket from that ‘end’ then drop down a line, add another end with a bracket on it.
You have no end for the function yet.

also, remove the second ‘then’

Okay, so a few things…

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid")then
		if game.Workspace.FactoryLasers.LaserButton.BrickColor == "Really red" then
			game.Workspace.NoLazerBadge.BadgeAwarderScript.Disabled = false
		end
	end
end)

The brick color isn’t a vector3, the .Color is. So if the color is “Really red” then do __. You also didn’t put 2 equal signs.

2 Likes
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if game.Workspace.FactoryLasers.LaserButton.BrickColor == BrickColor.new("Really red") then
		    game.Workspace.NoLazerBadge.BadgeAwarderScript.Disabled = false
		end
	end
end)

Still got some errors.

1 Like

But wouldn’t the “BrickColor.new” part not fit? Like I just want the function to work if that color is red. Wouldn’t the script then turn that part red since from the “BrickColor.new”?

And also, do I need an “else” statement?

1 Like

Two ‘=’ signs. It’s an ‘if’ statement.

1 Like

It should, if it doesn’t switch to Color.

They aren’t necessary unless you want something to happen in the alternate scenario, e.g. it kills the player if the button isn’t red.

1 Like