Advertisement
BobMe

Tic Tac Toe - Void

Jun 29th, 2020 (edited)
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.74 KB | None | 0 0
  1. -- Settings:
  2. local Player_ = owner
  3.  
  4. -- Guis
  5.  
  6. -- TicTacToe Gui
  7.  
  8. local TicTacToe = Instance.new("ScreenGui")
  9. local Background = Instance.new("Frame")
  10. local Bar = Instance.new("Frame")
  11. local Bar_2 = Instance.new("Frame")
  12. local Bar_3 = Instance.new("Frame")
  13. local Bar_4 = Instance.new("Frame")
  14. local Grid1 = Instance.new("TextButton")
  15. local Grid4 = Instance.new("TextButton")
  16. local Grid2 = Instance.new("TextButton")
  17. local Grid7 = Instance.new("TextButton")
  18. local Grid5 = Instance.new("TextButton")
  19. local Grid3 = Instance.new("TextButton")
  20. local Grid8 = Instance.new("TextButton")
  21. local Grid6 = Instance.new("TextButton")
  22. local Grid9 = Instance.new("TextButton")
  23. local XPlayer = Instance.new("TextLabel")
  24. local OPlayer = Instance.new("TextLabel")
  25.  
  26. -- Properties
  27.  
  28. TicTacToe.Name = "TicTacToe"
  29. TicTacToe.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  30. TicTacToe.ResetOnSpawn = false
  31.  
  32. Background.Name = "Background"
  33. Background.Parent = TicTacToe
  34. Background.AnchorPoint = Vector2.new(0.5, 0.5)
  35. Background.BackgroundColor3 = Color3.new(0.780392, 0.780392, 0.780392)
  36. Background.BackgroundTransparency = 0.5
  37. Background.BorderSizePixel = 0
  38. Background.Position = UDim2.new(0.5, 0, 0.5, 0)
  39. Background.Size = UDim2.new(0.349999994, 0, 0.349999994, 0)
  40. Background.SizeConstraint = Enum.SizeConstraint.RelativeXX
  41.  
  42. Bar.Name = "Bar"
  43. Bar.Parent = Background
  44. Bar.AnchorPoint = Vector2.new(0.5, 0)
  45. Bar.BackgroundColor3 = Color3.new(0, 0, 0)
  46. Bar.BorderSizePixel = 0
  47. Bar.Position = UDim2.new(0.333333343, 0, 0, 0)
  48. Bar.Size = UDim2.new(0.0250000004, 0, 1, 0)
  49.  
  50. Bar_2.Name = "Bar"
  51. Bar_2.Parent = Background
  52. Bar_2.AnchorPoint = Vector2.new(0.5, 0)
  53. Bar_2.BackgroundColor3 = Color3.new(0, 0, 0)
  54. Bar_2.BorderSizePixel = 0
  55. Bar_2.Position = UDim2.new(0.666666687, 0, 0, 0)
  56. Bar_2.Size = UDim2.new(0.0250000004, 0, 1, 0)
  57.  
  58. Bar_3.Name = "Bar"
  59. Bar_3.Parent = Background
  60. Bar_3.AnchorPoint = Vector2.new(0, 0.5)
  61. Bar_3.BackgroundColor3 = Color3.new(0, 0, 0)
  62. Bar_3.BorderSizePixel = 0
  63. Bar_3.Position = UDim2.new(0, 0, 0.333333343, 0)
  64. Bar_3.Size = UDim2.new(1, 0, 0.0250000004, 0)
  65.  
  66. Bar_4.Name = "Bar"
  67. Bar_4.Parent = Background
  68. Bar_4.AnchorPoint = Vector2.new(0, 0.5)
  69. Bar_4.BackgroundColor3 = Color3.new(0, 0, 0)
  70. Bar_4.BorderSizePixel = 0
  71. Bar_4.Position = UDim2.new(0, 0, 0.666666687, 0)
  72. Bar_4.Size = UDim2.new(1, 0, 0.0250000004, 0)
  73.  
  74. Grid1.Name = "Grid1"
  75. Grid1.Parent = Background
  76. Grid1.BackgroundColor3 = Color3.new(1, 1, 1)
  77. Grid1.BackgroundTransparency = 1
  78. Grid1.Size = UDim2.new(0.333333343, 0, 0.333333343, 0)
  79. Grid1.Font = Enum.Font.SourceSans
  80. Grid1.Text = ""
  81. Grid1.TextColor3 = Color3.new(0, 0, 0)
  82. Grid1.TextScaled = true
  83. Grid1.TextSize = 14
  84. Grid1.TextWrapped = true
  85.  
  86. Grid4.Name = "Grid4"
  87. Grid4.Parent = Background
  88. Grid4.BackgroundColor3 = Color3.new(1, 1, 1)
  89. Grid4.BackgroundTransparency = 1
  90. Grid4.Position = UDim2.new(0, 0, 0.333000004, 0)
  91. Grid4.Size = UDim2.new(0.333333343, 0, 0.333333343, 0)
  92. Grid4.Font = Enum.Font.SourceSans
  93. Grid4.Text = ""
  94. Grid4.TextColor3 = Color3.new(0, 0, 0)
  95. Grid4.TextScaled = true
  96. Grid4.TextSize = 14
  97. Grid4.TextWrapped = true
  98.  
  99. Grid2.Name = "Grid2"
  100. Grid2.Parent = Background
  101. Grid2.BackgroundColor3 = Color3.new(1, 1, 1)
  102. Grid2.BackgroundTransparency = 1
  103. Grid2.Position = UDim2.new(0.333333343, 0, 0, 0)
  104. Grid2.Size = UDim2.new(0.333333343, 0, 0.333333343, 0)
  105. Grid2.Font = Enum.Font.SourceSans
  106. Grid2.Text = ""
  107. Grid2.TextColor3 = Color3.new(0, 0, 0)
  108. Grid2.TextScaled = true
  109. Grid2.TextSize = 14
  110. Grid2.TextWrapped = true
  111.  
  112. Grid7.Name = "Grid7"
  113. Grid7.Parent = Background
  114. Grid7.BackgroundColor3 = Color3.new(1, 1, 1)
  115. Grid7.BackgroundTransparency = 1
  116. Grid7.Position = UDim2.new(0, 0, 0.666000009, 0)
  117. Grid7.Size = UDim2.new(0.333333343, 0, 0.333333343, 0)
  118. Grid7.Font = Enum.Font.SourceSans
  119. Grid7.Text = ""
  120. Grid7.TextColor3 = Color3.new(0, 0, 0)
  121. Grid7.TextScaled = true
  122. Grid7.TextSize = 14
  123. Grid7.TextWrapped = true
  124.  
  125. Grid5.Name = "Grid5"
  126. Grid5.Parent = Background
  127. Grid5.BackgroundColor3 = Color3.new(1, 1, 1)
  128. Grid5.BackgroundTransparency = 1
  129. Grid5.Position = UDim2.new(0.333333343, 0, 0.333000004, 0)
  130. Grid5.Size = UDim2.new(0.333333343, 0, 0.333333343, 0)
  131. Grid5.Font = Enum.Font.SourceSans
  132. Grid5.Text = ""
  133. Grid5.TextColor3 = Color3.new(0, 0, 0)
  134. Grid5.TextScaled = true
  135. Grid5.TextSize = 14
  136. Grid5.TextWrapped = true
  137.  
  138. Grid3.Name = "Grid3"
  139. Grid3.Parent = Background
  140. Grid3.BackgroundColor3 = Color3.new(1, 1, 1)
  141. Grid3.BackgroundTransparency = 1
  142. Grid3.Position = UDim2.new(0.666665971, 0, 0, 0)
  143. Grid3.Size = UDim2.new(0.333333343, 0, 0.333333343, 0)
  144. Grid3.Font = Enum.Font.SourceSans
  145. Grid3.Text = ""
  146. Grid3.TextColor3 = Color3.new(0, 0, 0)
  147. Grid3.TextScaled = true
  148. Grid3.TextSize = 14
  149. Grid3.TextWrapped = true
  150.  
  151. Grid8.Name = "Grid8"
  152. Grid8.Parent = Background
  153. Grid8.BackgroundColor3 = Color3.new(1, 1, 1)
  154. Grid8.BackgroundTransparency = 1
  155. Grid8.Position = UDim2.new(0.333333343, 0, 0.666000009, 0)
  156. Grid8.Size = UDim2.new(0.333333343, 0, 0.333333343, 0)
  157. Grid8.Font = Enum.Font.SourceSans
  158. Grid8.Text = ""
  159. Grid8.TextColor3 = Color3.new(0, 0, 0)
  160. Grid8.TextScaled = true
  161. Grid8.TextSize = 14
  162. Grid8.TextWrapped = true
  163.  
  164. Grid6.Name = "Grid6"
  165. Grid6.Parent = Background
  166. Grid6.BackgroundColor3 = Color3.new(1, 1, 1)
  167. Grid6.BackgroundTransparency = 1
  168. Grid6.Position = UDim2.new(0.666665971, 0, 0.333000004, 0)
  169. Grid6.Size = UDim2.new(0.333333343, 0, 0.333333343, 0)
  170. Grid6.Font = Enum.Font.SourceSans
  171. Grid6.Text = ""
  172. Grid6.TextColor3 = Color3.new(0, 0, 0)
  173. Grid6.TextScaled = true
  174. Grid6.TextSize = 14
  175. Grid6.TextWrapped = true
  176.  
  177. Grid9.Name = "Grid9"
  178. Grid9.Parent = Background
  179. Grid9.BackgroundColor3 = Color3.new(1, 1, 1)
  180. Grid9.BackgroundTransparency = 1
  181. Grid9.Position = UDim2.new(0.666665971, 0, 0.666000009, 0)
  182. Grid9.Size = UDim2.new(0.333333343, 0, 0.333333343, 0)
  183. Grid9.Font = Enum.Font.SourceSans
  184. Grid9.Text = ""
  185. Grid9.TextColor3 = Color3.new(0, 0, 0)
  186. Grid9.TextScaled = true
  187. Grid9.TextSize = 14
  188. Grid9.TextWrapped = true
  189.  
  190. XPlayer.Name = "XPlayer"
  191. XPlayer.Parent = Background
  192. XPlayer.AnchorPoint = Vector2.new(0, 1)
  193. XPlayer.BackgroundColor3 = Color3.new(1, 1, 1)
  194. XPlayer.BackgroundTransparency = 1
  195. XPlayer.Size = UDim2.new(0.449999988, 0, 0.0500000007, 0)
  196. XPlayer.Font = Enum.Font.SourceSans
  197. XPlayer.Text = "(X): Memo1332"
  198. XPlayer.TextColor3 = Color3.new(0, 0, 0)
  199. XPlayer.TextScaled = true
  200. XPlayer.TextSize = 14
  201. XPlayer.TextWrapped = true
  202. XPlayer.TextXAlignment = Enum.TextXAlignment.Left
  203. XPlayer.TextYAlignment = Enum.TextYAlignment.Bottom
  204.  
  205. OPlayer.Name = "OPlayer"
  206. OPlayer.Parent = Background
  207. OPlayer.AnchorPoint = Vector2.new(1, 1)
  208. OPlayer.BackgroundColor3 = Color3.new(1, 1, 1)
  209. OPlayer.BackgroundTransparency = 1
  210. OPlayer.Position = UDim2.new(1, 0, 0, 0)
  211. OPlayer.Size = UDim2.new(0.449999988, 0, 0.0500000007, 0)
  212. OPlayer.Font = Enum.Font.SourceSans
  213. OPlayer.Text = "sadpandu :(O)"
  214. OPlayer.TextColor3 = Color3.new(0, 0, 0)
  215. OPlayer.TextScaled = true
  216. OPlayer.TextSize = 14
  217. OPlayer.TextWrapped = true
  218. OPlayer.TextXAlignment = Enum.TextXAlignment.Right
  219. OPlayer.TextYAlignment = Enum.TextYAlignment.Bottom
  220.  
  221. -- Request GUI
  222.  
  223. local Request = Instance.new("ScreenGui")
  224. local Outer = Instance.new("Frame")
  225. local Inner = Instance.new("Frame")
  226. local TextLabel = Instance.new("TextLabel")
  227. local Exit = Instance.new("TextButton")
  228. local Back = Instance.new("Frame")
  229. local TextLabel_2 = Instance.new("TextLabel")
  230. local Yes = Instance.new("TextButton")
  231. local No = Instance.new("TextButton")
  232.  
  233. -- Properties
  234.  
  235. Request.Name = "Request"
  236. Request.Parent = game.ServerStorage
  237. Request.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  238. Request.ResetOnSpawn = false
  239.  
  240. Outer.Name = "Outer"
  241. Outer.Parent = Request
  242. Outer.AnchorPoint = Vector2.new(0.5, 0.5)
  243. Outer.BackgroundColor3 = Color3.new(1, 1, 1)
  244. Outer.BackgroundTransparency = 0.5
  245. Outer.BorderSizePixel = 0
  246. Outer.Position = UDim2.new(0.5, 0, 1, 0)
  247. Outer.Size = UDim2.new(0.5, 0, 0.400000006, 0)
  248.  
  249. Inner.Name = "Inner"
  250. Inner.Parent = Outer
  251. Inner.BackgroundColor3 = Color3.new(0, 0, 0)
  252. Inner.BackgroundTransparency = 0.5
  253. Inner.BorderColor3 = Color3.new(0.105882, 0.164706, 0.207843)
  254. Inner.BorderSizePixel = 0
  255. Inner.Size = UDim2.new(1, 0, 0.150000006, 0)
  256.  
  257. TextLabel.Parent = Inner
  258. TextLabel.BackgroundColor3 = Color3.new(1, 1, 1)
  259. TextLabel.BackgroundTransparency = 1
  260. TextLabel.BorderSizePixel = 0
  261. TextLabel.Size = UDim2.new(1, 0, 1, 0)
  262. TextLabel.Font = Enum.Font.SourceSans
  263. TextLabel.Text = "Invitation"
  264. TextLabel.TextColor3 = Color3.new(1, 1, 1)
  265. TextLabel.TextScaled = true
  266. TextLabel.TextSize = 14
  267. TextLabel.TextWrapped = true
  268. TextLabel.TextXAlignment = Enum.TextXAlignment.Left
  269.  
  270. Exit.Name = "Exit"
  271. Exit.Parent = Inner
  272. Exit.AnchorPoint = Vector2.new(1, 0)
  273. Exit.BackgroundColor3 = Color3.new(1, 1, 1)
  274. Exit.BackgroundTransparency = 1
  275. Exit.BorderSizePixel = 0
  276. Exit.Position = UDim2.new(1, 0, 0, 0)
  277. Exit.Size = UDim2.new(1, 0, 1, 0)
  278. Exit.SizeConstraint = Enum.SizeConstraint.RelativeYY
  279. Exit.Font = Enum.Font.SourceSans
  280. Exit.Text = "X"
  281. Exit.TextColor3 = Color3.new(1, 1, 1)
  282. Exit.TextScaled = true
  283. Exit.TextSize = 14
  284. Exit.TextWrapped = true
  285.  
  286. Back.Name = "Back"
  287. Back.Parent = Outer
  288. Back.BackgroundColor3 = Color3.new(1, 1, 1)
  289. Back.BackgroundTransparency = 1
  290. Back.Position = UDim2.new(0, 0, 0.150000006, 0)
  291. Back.Size = UDim2.new(1, 0, 0.850000024, 0)
  292.  
  293. TextLabel_2.Parent = Back
  294. TextLabel_2.BackgroundColor3 = Color3.new(1, 1, 1)
  295. TextLabel_2.BackgroundTransparency = 1
  296. TextLabel_2.Size = UDim2.new(1, 0, 0.699999988, 0)
  297. TextLabel_2.Font = Enum.Font.SourceSans
  298. TextLabel_2.Text = ""
  299. TextLabel_2.TextColor3 = Color3.new(0, 0, 0)
  300. TextLabel_2.TextScaled = true
  301. TextLabel_2.TextSize = 55
  302. TextLabel_2.TextWrapped = true
  303.  
  304. Yes.Name = "Yes"
  305. Yes.Parent = Back
  306. Yes.AnchorPoint = Vector2.new(1, 0)
  307. Yes.BackgroundColor3 = Color3.new(0, 0.74902, 0.0235294)
  308. Yes.BorderColor3 = Color3.new(0.254902, 0.835294, 0.211765)
  309. Yes.BorderSizePixel = 5
  310. Yes.Position = UDim2.new(0.449999988, 0, 0.800000012, 0)
  311. Yes.Size = UDim2.new(0.300000012, 0, 0.150000006, 0)
  312. Yes.Font = Enum.Font.SourceSans
  313. Yes.Text = "Yes"
  314. Yes.TextColor3 = Color3.new(1, 1, 1)
  315. Yes.TextScaled = true
  316. Yes.TextSize = 14
  317. Yes.TextWrapped = true
  318.  
  319. No.Name = "No"
  320. No.Parent = Back
  321. No.BackgroundColor3 = Color3.new(0.74902, 0, 0.0117647)
  322. No.BorderColor3 = Color3.new(0.835294, 0, 0.0117647)
  323. No.BorderSizePixel = 5
  324. No.Position = UDim2.new(0.550000012, 0, 0.800000012, 0)
  325. No.Size = UDim2.new(0.300000012, 0, 0.150000006, 0)
  326. No.Font = Enum.Font.SourceSans
  327. No.Text = "No"
  328. No.TextColor3 = Color3.new(1, 1, 1)
  329. No.TextScaled = true
  330. No.TextSize = 14
  331. No.TextWrapped = true
  332.  
  333. -- Deny GUI
  334.  
  335. local Deny = Instance.new("ScreenGui")
  336. local Tec = Instance.new("TextLabel")
  337.  
  338. -- Properties
  339.  
  340. Deny.Name = "Deny"
  341. Deny.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  342.  
  343. Tec.Name = "Tec"
  344. Tec.Parent = Deny
  345. Tec.AnchorPoint = Vector2.new(1, 1)
  346. Tec.BackgroundColor3 = Color3.new(0, 0, 0)
  347. Tec.BackgroundTransparency = 0.5
  348. Tec.Position = UDim2.new(1, -10, 1.1, -10)
  349. Tec.Size = UDim2.new(0.150000006, 0, 0.050999999, 0)
  350. Tec.Font = Enum.Font.SourceSans
  351. Tec.Text = "Player denied your request"
  352. Tec.TextColor3 = Color3.new(1, 1, 1)
  353. Tec.TextScaled = true
  354. Tec.TextSize = 14
  355. Tec.TextWrapped = true
  356.  
  357. -- Actual Script
  358.  
  359.  
  360. function findplayer(playername)
  361. for i,v in pairs(game.Players:GetChildren()) do
  362. local nam = v.Name
  363. if string.sub(nam,1,#playername):lower() == playername:lower() then
  364. return v
  365. end
  366. end
  367. return nil
  368. end
  369.  
  370. Player_.Chatted:Connect(function(message)
  371. coroutine.resume(coroutine.create(function()
  372. if string.sub(message,1,4):lower() == "1v1/" then
  373. local plr = findplayer(string.sub(message,5))
  374. if plr ~= nil then
  375. local response = nil
  376. local clon = Request:Clone()
  377. clon.Parent = plr.PlayerGui
  378. clon.Outer:TweenPosition(UDim2.new(0.5,0,0.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Back,0.5,true)
  379. clon.Outer.Back.TextLabel.Text = Player_.Name.." has invited you to play tic tac toe! Would you like to accept their invitation?"
  380. --
  381. clon.Outer.Back.No.MouseButton1Click:Connect(function()
  382. response = false
  383. end)
  384. clon.Outer.Inner.Exit.MouseButton1Click:Connect(function()
  385. response = false
  386. end)
  387. clon.Outer.Back.Yes.MouseButton1Click:Connect(function()
  388. response = true
  389. end)
  390. repeat wait() until response ~= nil
  391. clon:Destroy()
  392. if response == true then
  393. local antispam = false
  394. local clone1 = TicTacToe:Clone()
  395. local clone2 = TicTacToe:Clone()
  396. clone1.Parent = Player_.PlayerGui
  397. clone2.Parent = plr.PlayerGui
  398. clone1.Background.OPlayer.Text = plr.Name.." :(O)"
  399. clone2.Background.OPlayer.Text = plr.Name.." :(O)"
  400. clone1.Background.XPlayer.Text = "(X): "..Player_.Name
  401. clone2.Background.XPlayer.Text = "(X): "..Player_.Name
  402. for i,v in pairs(clone2.Background:GetChildren()) do
  403. if string.sub(v.Name,1,3) == "Bar" then
  404. v.BackgroundTransparency = 0.5
  405. end
  406. end
  407.  
  408. local xturn = true
  409.  
  410. local function istherewin()
  411. local k = clone1.Background
  412. local winner = "nobody"
  413. local code = nil
  414. local tex = ""
  415. if k.Grid1.Text == "X" then tex = tex.."x" elseif k.Grid1.Text == "O" then tex = tex.."o" else tex = tex.."." end
  416. if k.Grid2.Text == "X" then tex = tex.."x" elseif k.Grid2.Text == "O" then tex = tex.."o" else tex = tex.."." end
  417. if k.Grid3.Text == "X" then tex = tex.."x" elseif k.Grid3.Text == "O" then tex = tex.."o" else tex = tex.."." end
  418. if k.Grid4.Text == "X" then tex = tex.."x" elseif k.Grid4.Text == "O" then tex = tex.."o" else tex = tex.."." end
  419. if k.Grid5.Text == "X" then tex = tex.."x" elseif k.Grid5.Text == "O" then tex = tex.."o" else tex = tex.."." end
  420. if k.Grid6.Text == "X" then tex = tex.."x" elseif k.Grid6.Text == "O" then tex = tex.."o" else tex = tex.."." end
  421. if k.Grid7.Text == "X" then tex = tex.."x" elseif k.Grid7.Text == "O" then tex = tex.."o" else tex = tex.."." end
  422. if k.Grid8.Text == "X" then tex = tex.."x" elseif k.Grid8.Text == "O" then tex = tex.."o" else tex = tex.."." end
  423. if k.Grid9.Text == "X" then tex = tex.."x" elseif k.Grid9.Text == "O" then tex = tex.."o" else tex = tex.."." end
  424. print(tex)
  425.  
  426. --to make things neater:
  427. local function sub(num)
  428. return string.sub(tex,num,num)
  429. end
  430. if sub(1) == "x" and sub(5) == "x" and sub(9) == "x" then
  431. winner = "x"
  432. code = 159
  433. elseif sub(1) == "o" and sub(5) == "o" and sub(9) == "o" then
  434. winner = "o"
  435. code = 159
  436. elseif sub(3) == "x" and sub(5) == "x" and sub(7) == "x" then
  437. winner = "x"
  438. code = 357
  439. elseif sub(3) == "o" and sub(5) == "o" and sub(7) == "o" then
  440. winner = "o"
  441. code = 357
  442. elseif sub(1) == "x" and sub(2) == "x" and sub(3) == "x" then
  443. winner = "x"
  444. code = 123
  445. elseif sub(1) == "o" and sub(2) == "o" and sub(3) == "o" then
  446. winner = "o"
  447. code = 123
  448. elseif sub(4) == "x" and sub(5) == "x" and sub(6) == "x" then
  449. winner = "x"
  450. code = 456
  451. elseif sub(4) == "o" and sub(5) == "o" and sub(6) == "o" then
  452. winner = "o"
  453. code = 456
  454. elseif sub(7) == "x" and sub(8) == "x" and sub(9) == "x" then
  455. winner = "x"
  456. code = 789
  457. elseif sub(7) == "o" and sub(8) == "o" and sub(9) == "o" then
  458. winner = "o"
  459. code = 789
  460. elseif sub(1) == "x" and sub(4) == "x" and sub(7) == "x" then
  461. winner = "x"
  462. code = 147
  463. elseif sub(1) == "o" and sub(4) == "o" and sub(7) == "o" then
  464. winner = "o"
  465. code = 147
  466. elseif sub(2) == "x" and sub(5) == "x" and sub(8) == "x" then
  467. winner = "x"
  468. code = 258
  469. elseif sub(2) == "o" and sub(5) == "o" and sub(8) == "o" then
  470. winner = "o"
  471. code = 258
  472. elseif sub(3) == "x" and sub(6) == "x" and sub(9) == "x" then
  473. winner = "x"
  474. code = 369
  475. elseif sub(3) == "o" and sub(6) == "o" and sub(9) == "o" then
  476. winner = "o"
  477. code = 369
  478. elseif sub(1) ~= "." and sub(2) ~= "." and sub(3) ~= "." and sub(4) ~= "." and sub(5) ~= "." and sub(6) ~= "." and sub(7) ~= "." and sub(8) ~= "." and sub(9) ~= "." then
  479. winner = "cat"
  480. end
  481.  
  482. local function animateWinner()
  483. code = tostring(code)
  484. local grids = {}
  485. for i=1,#code do
  486. local num = (string.sub(code,i,i))
  487. table.insert(grids,clone1.Background:FindFirstChild("Grid"..num))
  488. table.insert(grids,clone2.Background:FindFirstChild("Grid"..num))
  489. end
  490. --
  491. for i=1,4 do
  492. for ii=1,#grids do
  493. grids[ii].TextColor3 = Color3.fromRGB(255, 200, 0)
  494. end
  495. wait(.3)
  496. for ii=1,#grids do
  497. grids[ii].TextColor3 = Color3.fromRGB(0, 0, 0)
  498. end
  499. wait(.3)
  500. end
  501. end
  502.  
  503. if winner == "x" or winner == "o" then
  504. xturn = nil
  505. animateWinner()
  506. wait(2)
  507. clone1:Destroy()
  508. clone2:Destroy()
  509. elseif winner == "cat" then
  510. wait(2)
  511. for i,v in pairs(clone1.Background:GetChildren()) do
  512. if string.sub(v.Name,1,4) == "Grid" then
  513. v.Text = ""
  514. end
  515. end
  516. for i,v in pairs(clone2.Background:GetChildren()) do
  517. if string.sub(v.Name,1,4) == "Grid" then
  518. v.Text = ""
  519. end
  520. end
  521. end
  522.  
  523. if xturn == true then
  524. for i,v in pairs(clone1.Background:GetChildren()) do
  525. if string.sub(v.Name,1,3) == "Bar" then
  526. v.BackgroundTransparency = 0
  527. end
  528. end
  529. for i,v in pairs(clone2.Background:GetChildren()) do
  530. if string.sub(v.Name,1,3) == "Bar" then
  531. v.BackgroundTransparency = 0.5
  532. end
  533. end
  534. elseif xturn == false then
  535. for i,v in pairs(clone1.Background:GetChildren()) do
  536. if string.sub(v.Name,1,3) == "Bar" then
  537. v.BackgroundTransparency = 0.5
  538. end
  539. end
  540. for i,v in pairs(clone2.Background:GetChildren()) do
  541. if string.sub(v.Name,1,3) == "Bar" then
  542. v.BackgroundTransparency = 0
  543. end
  544. end
  545. end
  546. end
  547.  
  548. clone1.Background.Grid1.MouseButton1Click:Connect(function()
  549. if xturn == true and antispam == false and clone1.Background.Grid1.Text == "" then
  550. antispam = true
  551. xturn = false
  552. clone1.Background.Grid1.Text = "X"
  553. clone2.Background.Grid1.Text = "X"
  554. wait(.5)
  555. istherewin()
  556. wait(.25)
  557. antispam = false
  558. end
  559. end)
  560. clone1.Background.Grid2.MouseButton1Click:Connect(function()
  561. if xturn == true and antispam == false and clone1.Background.Grid2.Text == "" then
  562. antispam = true
  563. xturn = false
  564. clone1.Background.Grid2.Text = "X"
  565. clone2.Background.Grid2.Text = "X"
  566. wait(.5)
  567. istherewin()
  568. wait(.25)
  569. antispam = false
  570. end
  571. end)
  572. clone1.Background.Grid3.MouseButton1Click:Connect(function()
  573. if xturn == true and antispam == false and clone1.Background.Grid3.Text == "" then
  574. antispam = true
  575. xturn = false
  576. clone1.Background.Grid3.Text = "X"
  577. clone2.Background.Grid3.Text = "X"
  578. wait(.5)
  579. istherewin()
  580. wait(.25)
  581. antispam = false
  582. end
  583. end)
  584. clone1.Background.Grid4.MouseButton1Click:Connect(function()
  585. if xturn == true and antispam == false and clone1.Background.Grid4.Text == "" then
  586. antispam = true
  587. xturn = false
  588. clone1.Background.Grid4.Text = "X"
  589. clone2.Background.Grid4.Text = "X"
  590. wait(.5)
  591. istherewin()
  592. wait(.25)
  593. antispam = false
  594. end
  595. end)
  596. clone1.Background.Grid5.MouseButton1Click:Connect(function()
  597. if xturn == true and antispam == false and clone1.Background.Grid5.Text == "" then
  598. antispam = true
  599. xturn = false
  600. clone1.Background.Grid5.Text = "X"
  601. clone2.Background.Grid5.Text = "X"
  602. wait(.5)
  603. istherewin()
  604. wait(.25)
  605. antispam = false
  606. end
  607. end)
  608. clone1.Background.Grid6.MouseButton1Click:Connect(function()
  609. if xturn == true and antispam == false and clone1.Background.Grid6.Text == "" then
  610. antispam = true
  611. xturn = false
  612. clone1.Background.Grid6.Text = "X"
  613. clone2.Background.Grid6.Text = "X"
  614. wait(.5)
  615. istherewin()
  616. wait(.25)
  617. antispam = false
  618. end
  619. end)
  620. clone1.Background.Grid7.MouseButton1Click:Connect(function()
  621. if xturn == true and antispam == false and clone1.Background.Grid7.Text == "" then
  622. antispam = true
  623. xturn = false
  624. clone1.Background.Grid7.Text = "X"
  625. clone2.Background.Grid7.Text = "X"
  626. wait(.5)
  627. istherewin()
  628. wait(.25)
  629. antispam = false
  630. end
  631. end)
  632. clone1.Background.Grid8.MouseButton1Click:Connect(function()
  633. if xturn == true and antispam == false and clone1.Background.Grid8.Text == "" then
  634. antispam = true
  635. xturn = false
  636. clone1.Background.Grid8.Text = "X"
  637. clone2.Background.Grid8.Text = "X"
  638. wait(.5)
  639. istherewin()
  640. wait(.25)
  641. antispam = false
  642. end
  643. end)
  644. clone1.Background.Grid9.MouseButton1Click:Connect(function()
  645. if xturn == true and antispam == false and clone1.Background.Grid9.Text == "" then
  646. antispam = true
  647. xturn = false
  648. clone1.Background.Grid9.Text = "X"
  649. clone2.Background.Grid9.Text = "X"
  650. wait(.5)
  651. istherewin()
  652. wait(.25)
  653. antispam = false
  654. end
  655. end)
  656. ------------------------------------------------------------------------------------------------------------
  657. clone2.Background.Grid1.MouseButton1Click:Connect(function()
  658. if xturn == false and antispam == false and clone2.Background.Grid1.Text == "" then
  659. antispam = true
  660. xturn = true
  661. clone1.Background.Grid1.Text = "O"
  662. clone2.Background.Grid1.Text = "O"
  663. wait(.5)
  664. istherewin()
  665. wait(.25)
  666. antispam = false
  667. end
  668. end)
  669. clone2.Background.Grid2.MouseButton1Click:Connect(function()
  670. if xturn == false and antispam == false and clone2.Background.Grid2.Text == "" then
  671. antispam = true
  672. xturn = true
  673. clone1.Background.Grid2.Text = "O"
  674. clone2.Background.Grid2.Text = "O"
  675. wait(.5)
  676. istherewin()
  677. wait(.25)
  678. antispam = false
  679. end
  680. end)
  681. clone2.Background.Grid3.MouseButton1Click:Connect(function()
  682. if xturn == false and antispam == false and clone2.Background.Grid3.Text == "" then
  683. antispam = true
  684. xturn = true
  685. clone1.Background.Grid3.Text = "O"
  686. clone2.Background.Grid3.Text = "O"
  687. wait(.5)
  688. istherewin()
  689. wait(.25)
  690. antispam = false
  691. end
  692. end)
  693. clone2.Background.Grid4.MouseButton1Click:Connect(function()
  694. if xturn == false and antispam == false and clone2.Background.Grid4.Text == "" then
  695. antispam = true
  696. xturn = true
  697. clone1.Background.Grid4.Text = "O"
  698. clone2.Background.Grid4.Text = "O"
  699. wait(.5)
  700. istherewin()
  701. wait(.25)
  702. antispam = false
  703. end
  704. end)
  705. clone2.Background.Grid5.MouseButton1Click:Connect(function()
  706. if xturn == false and antispam == false and clone2.Background.Grid5.Text == "" then
  707. antispam = true
  708. xturn = true
  709. clone1.Background.Grid5.Text = "O"
  710. clone2.Background.Grid5.Text = "O"
  711. wait(.5)
  712. istherewin()
  713. wait(.25)
  714. antispam = false
  715. end
  716. end)
  717. clone2.Background.Grid6.MouseButton1Click:Connect(function()
  718. if xturn == false and antispam == false and clone2.Background.Grid6.Text == "" then
  719. antispam = true
  720. xturn = true
  721. clone1.Background.Grid6.Text = "O"
  722. clone2.Background.Grid6.Text = "O"
  723. wait(.5)
  724. istherewin()
  725. wait(.25)
  726. antispam = false
  727. end
  728. end)
  729. clone2.Background.Grid7.MouseButton1Click:Connect(function()
  730. if xturn == false and antispam == false and clone2.Background.Grid7.Text == "" then
  731. antispam = true
  732. xturn = true
  733. clone1.Background.Grid7.Text = "O"
  734. clone2.Background.Grid7.Text = "O"
  735. wait(.5)
  736. istherewin()
  737. wait(.25)
  738. antispam = false
  739. end
  740. end)
  741. clone2.Background.Grid8.MouseButton1Click:Connect(function()
  742. if xturn == false and antispam == false and clone2.Background.Grid8.Text == "" then
  743. antispam = true
  744. xturn = true
  745. clone1.Background.Grid8.Text = "O"
  746. clone2.Background.Grid8.Text = "O"
  747. wait(.5)
  748. istherewin()
  749. wait(.25)
  750. antispam = false
  751. end
  752. end)
  753. clone2.Background.Grid9.MouseButton1Click:Connect(function()
  754. if xturn == false and antispam == false and clone2.Background.Grid9.Text == "" then
  755. antispam = true
  756. xturn = true
  757. clone1.Background.Grid9.Text = "O"
  758. clone2.Background.Grid9.Text = "O"
  759. wait(.5)
  760. istherewin()
  761. wait(.25)
  762. antispam = false
  763. end
  764. end)
  765. else
  766. local clon = Deny:Clone()
  767. clon.Parent = Player_.PlayerGui
  768. clon.Tec.Text = plr.Name.." denied your request"
  769. coroutine.resume(coroutine.create(function()
  770. clon.Tec:TweenPosition(UDim2.new(1,-10,1,-10),Enum.EasingDirection.Out,Enum.EasingStyle.Back,0.3,true)
  771. for i=1,3 do
  772. clon.Tec.BackgroundColor3 = Color3.fromRGB(255,0,0)
  773. wait(.3)
  774. clon.Tec.BackgroundColor3 = Color3.fromRGB(0,0,0)
  775. wait(.3)
  776. end
  777. wait(3)
  778. clon.Tec:TweenPosition(UDim2.new(1,-10,1.1,-10),Enum.EasingDirection.In,Enum.EasingStyle.Back,0.5,true)
  779. wait(0.5)
  780. clon:Destroy()
  781. end))
  782. end
  783. end
  784. elseif message:lower() == ";clear" then
  785. for i,v in pairs(Player_.PlayerGui:GetChildren()) do
  786. if v.Name == "Request" or v.Name == "TicTacToe" then
  787. v:Destroy()
  788. end
  789. end
  790. end
  791. end))
  792. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement