i tried to make when player click on brick then math.random then brick changing color, but it not works
script.Parent.MouseClick:Connect(function() local number = math.random(1, 2) number = math.random(1, 2) print(number) if math == 1 then print("1") script.Parent.Parent.BrickColor = BrickColor.Random() if math == 2 then script.Parent.Parent.BrickColor = BrickColor.Random() print("2") end end end)
Maybe switching out the if math to if number will work + i added "elseif" so if the number isnt 1 it will do number 2
script.Parent.MouseClick:Connect(function() local number = math.random(1, 2) number = math.random(1, 2) print(number) if number == 1 then print("1") script.Parent.Parent.BrickColor = BrickColor.Random() elseif number == 2 then script.Parent.Parent.BrickColor = BrickColor.Random() print("2") end end end)
If this doesn't work try to keep the "elseif" and switch back to "if math" instead of "if number"
Hopefully this works/helps!
You can delete that math.random. Because the number was 1 or 2 same to random brick color.
script.Parent.MouseClick:Connect(function() -- fire the MouseClick Event function OnClicked() -- when clicked script.Parent.Parent.BrickColor = BrickColor.Random() -- Random brickColor print(math.random(1, 2) -- print 1 or 2 end) -- end (if you end a function then you need to use 'end)' ) script.Parent.MouseClick:Connect(function(OnClicked) -- when clicked fire the OnClicked function