buttons =
script.Parent.Buttons:GetChildren()
script.Parent.Result.Text = "Result"
function
check_win_X()
if buttons[1].Text == "X" and buttons[2].Text == "X" and buttons[3].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[4].Text == "X" and buttons[5].Text == "X" and buttons[6].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[7].Text == "X" and buttons[8].Text == "X" and buttons[9].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[1].Text == "X" and
buttons[4].Text == "X" and buttons[7].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[2].Text == "X" and buttons[5].Text == "X" and buttons[8].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[3].Text == "X" and buttons[6].Text == "X" and buttons[9].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[1].Text == "X" and
buttons[5].Text == "X" and buttons[9].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[3].Text == "X" and buttons[5].Text == "X" and buttons[7].Text == "X" then
script.Parent.Result.Text = "X win"
end
end
script.Parent.Result.Text = "Result"
if buttons[1].Text == "X" and buttons[2].Text == "X" and buttons[3].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[4].Text == "X" and buttons[5].Text == "X" and buttons[6].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[7].Text == "X" and buttons[8].Text == "X" and buttons[9].Text == "X" then
script.Parent.Result.Text = "X win"
end
script.Parent.Result.Text = "X win"
end
if buttons[2].Text == "X" and buttons[5].Text == "X" and buttons[8].Text == "X" then
script.Parent.Result.Text = "X win"
end
if buttons[3].Text == "X" and buttons[6].Text == "X" and buttons[9].Text == "X" then
script.Parent.Result.Text = "X win"
end
script.Parent.Result.Text = "X win"
end
if buttons[3].Text == "X" and buttons[5].Text == "X" and buttons[7].Text == "X" then
script.Parent.Result.Text = "X win"
end
end
if buttons[1].Text == "0" and buttons[2].Text == "0" and buttons[3].Text == "0" then
script.Parent.Result.Text = "0 win"
end
if buttons[4].Text == "0" and buttons[5].Text == "0" and buttons[6].Text == "0" then
script.Parent.Result.Text = "0 win"
end
if buttons[7].Text == "0" and buttons[8].Text == "0" and buttons[9].Text == "0" then
script.Parent.Result.Text = "0 win"
end
script.Parent.Result.Text = "0 win"
end
if buttons[2].Text == "0" and buttons[5].Text == "0" and buttons[8].Text == "0" then
script.Parent.Result.Text = "0 win"
end
if buttons[3].Text == "0" and buttons[6].Text == "0" and buttons[9].Text == "0" then
script.Parent.Result.Text = "0 win"
end
script.Parent.Result.Text = "0 win"
end
if buttons[3].Text == "0" and buttons[5].Text == "0" and buttons[7].Text == "0" then
script.Parent.Result.Text = "0 win"
end
end
wait()
-- рандомний хід комп'ютера
--local rand = math.random(1,9)
--buttons[rand].Text = "0"
--check_win_0()
for i=1,9,1 do
if buttons[i].Text == "" then
buttons[i].Text = "0"
check_win_0()
a=false
break
end
end
--check_win_0()
else
for i=1, #buttons do
buttons[i].MouseButton1Click:Connect(function()
buttons[i].Text = "X"
check_win_X()
a = true
end)
end
end
end
Немає коментарів:
Дописати коментар