RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create tic tac toe script for 2 players"
-- server script local ticTacToeBoard = script.Parent local player1 = nil local player2 = nil local turn = 0 local function onClicked(part) if part.Parent ~= ticTacToeBoard then return end if turn == 0 then part.BrickColor = BrickColor.new("Bright blue") turn = 1 player1 = part elseif turn == 1 then part.BrickColor = BrickColor.new("Bright red") turn = 0 player2 = part end if player1 and player2 then if player1.Position.X == player2.Position.X then print("Player 1 Wins!") elseif player1.Position.Y == player2.Position.Y then print("Player 1 Wins!") elseif player1.Position.Z == player2.Position.Z then print("Player 1 Wins!") else print("Player 2 Wins!") end end end ticTacToeBoard.Touched:Connect(onClicked)