Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(1)
- local p = game.Players.asbuff
- local c = p.Character
- local hb = Instance.new("Tool")
- hb.Name = "X AND O GAME"
- local hb2 = Instance.new("Tool")
- hb2.Name = "CLEAR"
- local temp = Instance.new("Part")
- temp.Size = Vector3.new(3,1,3)
- temp.Anchored = true
- temp.CanCollide = false
- temp.Locked = true
- function creategame()
- local board = {}
- local connections = {}
- connections[1] = hb2.Activated:connect(function()
- for x = 1,3 do
- for y = 1,3 do
- board[x][y]:Destroy()
- end
- end
- end)
- for x = 1,3 do
- if board[x] == nil then board[x] = {} end
- for y = 1,3 do
- board[x][y] = temp:Clone()
- board[x][y].Parent = workspace.Terrain
- board[x][y].CFrame = c.Torso.CFrame * CFrame.new(x*3.1,-2.5,y*3.1)
- board[x][y].BrickColor = BrickColor.Black()
- if x == 2 and y == 2 then
- local text = Instance.new("BillboardGui",board[x][y])
- text.Size = UDim2.new(1,0,1,0)
- local text2 = Instance.new("TextLabel",text)
- text2.BackgroundTransparency = 1
- text2.TextScaled = true
- text2.Text = "ticc tacc toe against " .. p.Name
- text.StudsOffset = Vector3.new(0,5,0)
- text2.Size = UDim2.new(6,0,1,0)
- text2.AnchorPoint = Vector2.new(.5,.5)
- text2.TextStrokeColor3 = Color3.new()
- text2.TextColor3 = Color3.new(1,1,1)
- text2.TextStrokeTransparency = 0
- end
- end
- end
- local turn = true
- function checkwin(color)
- local stuffs = {}
- for x = 1,3 do
- local same = true
- stuffs = {}
- for y = 1,3 do
- stuffs[#stuffs+1] = board[x][y]
- if board[x][y].BrickColor ~= color then
- same = false
- end
- end
- if same then return true,stuffs end
- end
- for y = 1,3 do
- local same2 = true
- stuffs = {}
- for x = 1,3 do
- stuffs[#stuffs+1] = board[x][y]
- if board[x][y].BrickColor ~= color then
- same2 = false
- end
- end
- if same2 then return true,stuffs end
- end
- local same3 = true
- stuffs = {}
- for xy = 1,3 do
- stuffs[#stuffs+1] = board[xy][xy]
- if board[xy][xy].BrickColor ~= color then
- same3 = false
- end
- end
- if same3 then return true,stuffs end
- local same4 = true
- stuffs = {}
- for xy = 1,3 do
- stuffs[#stuffs+1] = board[xy][4-xy]
- if board[xy][4-xy].BrickColor ~= color then
- same4 = false
- end
- end
- if same4 then return true,stuffs end
- return false
- end
- local debouncewait = tick()
- for x = 1,3 do
- for y = 1,3 do
- local v = board[x][y]
- local num = #connections+1
- local cd = Instance.new("ClickDetector")
- cd.Parent = v
- connections[num] = cd.MouseClick:connect(function(plr)
- if debouncewait > tick() then return false end
- debouncewait = tick() + .5
- local cand = false
- if turn == true then
- if plr.Name == p.Name then
- v.BrickColor = BrickColor.Red()
- local decal = Instance.new("Decal",v)
- decal.Texture = "http://www.roblox.com/asset/?id=10952446"
- decal.Face = "Top"
- turn = not turn
- cand = true
- end
- else
- v.BrickColor = BrickColor.Blue()
- local decal = Instance.new("Decal",v)
- decal.Texture = "http://www.roblox.com/asset/?id=195452648"
- decal.Face = "Top"
- turn = not turn
- cand = true
- end
- local redwin,stuffs = checkwin(BrickColor.Red())
- local bluewin,stuffs2 = checkwin(BrickColor.Blue())
- if redwin == true then
- print("I WIN")
- for i,v in next,stuffs do
- v.Reflectance = .5
- v.BrickColor = BrickColor.new("New Yeller")
- end
- for x = 1,3 do
- for y = 1,3 do
- delay(1.5,function()
- board[x][y]:Destroy()
- end)
- end
- end
- elseif bluewin == true then
- print("YOU WIN")
- for i,v in next,stuffs2 do
- v.Reflectance = .5
- v.BrickColor = BrickColor.new("New Yeller")
- end
- for x = 1,3 do
- for y = 1,3 do
- delay(1.5,function()
- board[x][y]:Destroy()
- end)
- end
- end
- end
- if cand == true then
- connections[num]:disconnect()
- end
- end)
- end
- end
- end
- function onActivation()
- creategame()
- end
- hb.Activated:connect(onActivation)
- local handle = Instance.new("Part",hb)
- handle.Name = "Handle"
- handle.Size = Vector3.new(.5,.5,.5)
- local handle = Instance.new("Part",hb2)
- handle.Name = "Handle"
- handle.Size = Vector3.new(.5,.5,.5)
- hb.Parent = p.Backpack
- hb2.Parent = p.Backpack
- while wait() do
- if hb == nil then
- script:Destroy()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement