✓ Accepted answer
You forgot to add an "end" for your first "if" statement. You can add it on line 6.
I must also mention that there's a problem on line 9. Because you are looking for the name of the player who clicked the ClickDetector, you want to put after the two = signs this: playersInRedRoom[1].Name
Notice that I added Name. That is because if you just look for the first player in the table, it's not going to equal click.Name. Why? Well because a player does not equal their name. You must do click.Name == playersInRedRoom[1].Name; otherwise, it would always print nil instead of "hi".
I will show you what I am talking about by editing your Script:
local playersInRedRoom = {}
RedClickDetector.MouseClick:Connect(function(player)
if #playersInRedRoom < 2 then
table.insert(playersInRedRoom, player.Name)
end
local redWinPart = workspace.RedRoom.Win.ClickDetector
redWinPart.MouseClick:Connect(function(click)
if click.Name == playersInRedRoom[1].Name then
print("hi")
end
end)
Hope this helps!