I'm wondering why it's underlining the equals sign on this script. (=)

Read this to get an idea on how to know what’s going on here. Read the replies too: How can I make my character be able to go on a block if I press a button?


Anyway, there’s a script I got help from and I’m wondering how I can make my block CHANGE colors IF I click it with my cursor. Here’s my script:

`local clickable_button = script.Parent.Parent

if AppearBlock.CanCollide = true then – Here is where my problem is.

wait(3)

game.Workspace.AppearBlock.BrickColor.new(“Bright Green”)

game.workspace.AppearBlock.Transparency = 0

local Block = workspace.AppearBlock

clickable_button.ClickDetector.MouseClick:Connect(function()

Block.CanCollide = true

end)`

So yeah, on line 2 it says: if AppearBlock.CanCollide = true then. But the problem is, is that the equals sign (=) is underlined in red. I’m not sure why. So if you could answer that, you’re going to get a solution.

Change that = to == sign since = is assignment and == is equality comparison.

Also note you don’t need == true / == false. Just do if block.CanCollide then if you need to see if its collisions are enabled. Do if not block.CanCollide then if you need to see the opposite.

2 Likes

I spot two problems… you need to add two equal signs (==), that’s why it’s underlines. Secondly, there is a ‘)’ after end which needs to be removed.

1 Like

Thanks, @incapaxx and @doyouevenbruh33!