I made a script where it changes to random brick colors, and I want to make it so that when the color randomly goes to white, it damages the players and takes away some health. Except, it always takes away health weather the color is white or not. Here are my scripts that are in the part:
while true do script.Parent.BrickColor = BrickColor.Random() wait(2) end
(in 2 different scripts)
while true do if script.parent.BrickColor == BrickColor.White() or BrickColor.new("Institutional white") or BrickColor.new("Pearl") or BrickColor.new("Lily white") or BrickColor.new("Quill grey") or BrickColor.new("Mid gray") or BrickColor.new("Ghost grey") then function onTouch(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then humanoid.Health = -25 end end script.Parent.Touched:connect(onTouch) end wait(.01) end
Do you see any problems with it? Thank you in advance!