How to check if a bricks color is bright red and set its collision to false

You can write your topic however you want, but you need to answer these questions:
I have a game with a classic paintball gun that changes the colors of bricks when you shoot them. I wanted to make a brick where if you turn it ‘bright red’, it will lose collision and set its transparency to 0.5 to reveal a secret path.

Here’s what I have so far:

if (script.parent.BrickColor == BrickColor.Bright_red) then
	script.parent.cancollide = false
	script.parent.transparency = 0.5
end	

When I shoot the part with the paintball gun until it turns red, it doesn’t do anything.

I looked around for an answer, but couldn’t find anything.

2 Likes

I think that this

BrickColor.Bright_red

Needs to be This

BrickColor["Bright_red"] 
2 Likes
if script.parent.BrickColor == BrickColor.new("Bright red") then
	script.parent.CanCollide = false
	script.parent.Transparency = 0.5
end	

Try this

3 Likes

Pretty sure brickcolor is an enum but you should be able to check script.Parent.BrickColor == 21
21
or check if BrickColor == BrickColor.new(“Bright Red”), but this will cause memory issues iirc

1 Like

I tried that along with a few other things, but it still doesn’t work

2 Likes

Are you sure it’s “Bright Red”? Seems to be working fine for me.

Does the output say anything?

2 Likes

Can I see the props of the part?

2 Likes

image

1 Like

Have you tried modifying the paintball hit script and adding a few more lines like:

hit.CanCollide = false
hit.Transparency = 0.5
2 Likes

it works if the part is already bright red when I start the game, but not when I turn it red with the paintball gun

1 Like

I’m guessing this is what you want, although adding too many connections can lead to memory problems

script.Parent:GetPropertyChangedSignal("BrickColor"):Connect(function()
	if script.parent.BrickColor == BrickColor.new("Bright red") then
		script.parent.CanCollide = false
		script.parent.Transparency = 0.5
	end
end)
3 Likes

If he just wants it for specific parts then this works. If he were to modify the paintball code to set cancollide to false then players will fall out of the map when they hit the baseplate or the floor.

1 Like