I wrote this block of code and it ran fine
function win_condition()
local b1 = game.Workspace.b1.BrickColor.Name
local b2 = game.Workspace.b2.BrickColor.Name
local b3 = game.Workspace.b3.BrickColor.Name
local bg = "Bright green"
if b1 == bg and b2 == bg and b3 == bg then
print("bingo!")
end
end
script.Parent.ClickDetector.MouseClick:Connect(function()
script.Parent.BrickColor = BrickColor.new("Bright green")
win_condition()
end)
However, when I tried to make the part change to different colors depending on the team of the player (who clicked), a weird problem came up.
function win_condition()
local b1 = game.Workspace.b1.BrickColor.Name
local b2 = game.Workspace.b2.BrickColor.Name
local b3 = game.Workspace.b3.BrickColor.Name
local bg = "Bright green"
if b1 == bg and b2 == bg and b3 == bg then
print("bingo!")
end
end
**
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.Team == game.Teams.circles then
script.Parent.BrickColor = BrickColor.new("Bright green")
elseif player.Team == game.Teams.crosses then
script.Parent.BrickColor = BrickColor.new("Bright red")
end**
win_condition()
end)
The code still ran but the function "win_condition()" no longer worked properly. It would only print "bingo!" when each part was clicked TWICE.
When all 3 parts were changed to Bright green, it wouldn't react. However, if I clicked each part a second time, the function would run.
Sorry if I worded this strangely Many thanks

2 comments
Thank you for replying! I changed my code but the problem still persisted. This is really weird haha
Nvm it worked! Thank you!!!!