Advertisement
Aeyao

sadfghj54rtu6d5tyghyew5rdfhtshfghskhgdfjfhdg

Jul 4th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. wait(1)
  2. local p = game.Players.asbuff
  3. local c = p.Character
  4.  
  5. local hb = Instance.new("Tool")
  6. hb.Name = "X AND O GAME"
  7.  
  8. local hb2 = Instance.new("Tool")
  9. hb2.Name = "CLEAR"
  10.  
  11. local temp = Instance.new("Part")
  12. temp.Size = Vector3.new(3,1,3)
  13. temp.Anchored = true
  14. temp.CanCollide = false
  15. temp.Locked = true
  16.  
  17. function creategame()
  18.  
  19. local board = {}
  20. local connections = {}
  21.  
  22. connections[1] = hb2.Activated:connect(function()
  23. for x = 1,3 do
  24. for y = 1,3 do
  25. board[x][y]:Destroy()
  26. end
  27. end
  28. end)
  29.  
  30. for x = 1,3 do
  31. if board[x] == nil then board[x] = {} end
  32. for y = 1,3 do
  33. board[x][y] = temp:Clone()
  34. board[x][y].Parent = workspace.Terrain
  35. board[x][y].CFrame = c.Torso.CFrame * CFrame.new(x*3.1,-2.5,y*3.1)
  36. board[x][y].BrickColor = BrickColor.Black()
  37. if x == 2 and y == 2 then
  38. local text = Instance.new("BillboardGui",board[x][y])
  39. text.Size = UDim2.new(1,0,1,0)
  40. local text2 = Instance.new("TextLabel",text)
  41. text2.BackgroundTransparency = 1
  42. text2.TextScaled = true
  43. text2.Text = "ticc tacc toe against " .. p.Name
  44. text.StudsOffset = Vector3.new(0,5,0)
  45. text2.Size = UDim2.new(6,0,1,0)
  46. text2.AnchorPoint = Vector2.new(.5,.5)
  47. text2.TextStrokeColor3 = Color3.new()
  48. text2.TextColor3 = Color3.new(1,1,1)
  49. text2.TextStrokeTransparency = 0
  50. end
  51. end
  52. end
  53.  
  54. local turn = true
  55.  
  56. function checkwin(color)
  57.  
  58. local stuffs = {}
  59.  
  60. for x = 1,3 do
  61. local same = true
  62. stuffs = {}
  63. for y = 1,3 do
  64. stuffs[#stuffs+1] = board[x][y]
  65. if board[x][y].BrickColor ~= color then
  66. same = false
  67. end
  68. end
  69.  
  70. if same then return true,stuffs end
  71. end
  72.  
  73. for y = 1,3 do
  74. local same2 = true
  75. stuffs = {}
  76. for x = 1,3 do
  77. stuffs[#stuffs+1] = board[x][y]
  78. if board[x][y].BrickColor ~= color then
  79. same2 = false
  80. end
  81. end
  82.  
  83. if same2 then return true,stuffs end
  84. end
  85.  
  86. local same3 = true
  87. stuffs = {}
  88. for xy = 1,3 do
  89. stuffs[#stuffs+1] = board[xy][xy]
  90. if board[xy][xy].BrickColor ~= color then
  91. same3 = false
  92. end
  93. end
  94.  
  95. if same3 then return true,stuffs end
  96.  
  97. local same4 = true
  98. stuffs = {}
  99. for xy = 1,3 do
  100. stuffs[#stuffs+1] = board[xy][4-xy]
  101. if board[xy][4-xy].BrickColor ~= color then
  102. same4 = false
  103. end
  104. end
  105.  
  106. if same4 then return true,stuffs end
  107.  
  108. return false
  109.  
  110. end
  111.  
  112. local debouncewait = tick()
  113.  
  114. for x = 1,3 do
  115. for y = 1,3 do
  116. local v = board[x][y]
  117. local num = #connections+1
  118.  
  119. local cd = Instance.new("ClickDetector")
  120. cd.Parent = v
  121.  
  122. connections[num] = cd.MouseClick:connect(function(plr)
  123.  
  124. if debouncewait > tick() then return false end
  125. debouncewait = tick() + .5
  126.  
  127. local cand = false
  128. if turn == true then
  129. if plr.Name == p.Name then
  130. v.BrickColor = BrickColor.Red()
  131. local decal = Instance.new("Decal",v)
  132. decal.Texture = "http://www.roblox.com/asset/?id=10952446"
  133. decal.Face = "Top"
  134. turn = not turn
  135. cand = true
  136. end
  137. else
  138. v.BrickColor = BrickColor.Blue()
  139. local decal = Instance.new("Decal",v)
  140. decal.Texture = "http://www.roblox.com/asset/?id=195452648"
  141. decal.Face = "Top"
  142. turn = not turn
  143. cand = true
  144. end
  145.  
  146. local redwin,stuffs = checkwin(BrickColor.Red())
  147. local bluewin,stuffs2 = checkwin(BrickColor.Blue())
  148.  
  149. if redwin == true then
  150. print("I WIN")
  151. for i,v in next,stuffs do
  152. v.Reflectance = .5
  153. v.BrickColor = BrickColor.new("New Yeller")
  154. end
  155.  
  156. for x = 1,3 do
  157. for y = 1,3 do
  158. delay(1.5,function()
  159. board[x][y]:Destroy()
  160. end)
  161. end
  162. end
  163.  
  164. elseif bluewin == true then
  165. print("YOU WIN")
  166. for i,v in next,stuffs2 do
  167. v.Reflectance = .5
  168. v.BrickColor = BrickColor.new("New Yeller")
  169. end
  170.  
  171. for x = 1,3 do
  172. for y = 1,3 do
  173. delay(1.5,function()
  174. board[x][y]:Destroy()
  175. end)
  176. end
  177. end
  178. end
  179.  
  180. if cand == true then
  181. connections[num]:disconnect()
  182. end
  183.  
  184. end)
  185. end
  186. end
  187.  
  188. end
  189.  
  190. function onActivation()
  191. creategame()
  192. end
  193.  
  194. hb.Activated:connect(onActivation)
  195.  
  196. local handle = Instance.new("Part",hb)
  197. handle.Name = "Handle"
  198. handle.Size = Vector3.new(.5,.5,.5)
  199.  
  200. local handle = Instance.new("Part",hb2)
  201. handle.Name = "Handle"
  202. handle.Size = Vector3.new(.5,.5,.5)
  203.  
  204. hb.Parent = p.Backpack
  205. hb2.Parent = p.Backpack
  206.  
  207. while wait() do
  208. if hb == nil then
  209. script:Destroy()
  210. end
  211. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement