Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. openupalot = function(model,part)
  2. for i, v in pairs(model:GetChildren()) do
  3. if v ~= part and (v.Position-part.Position).Magnitude < 3 and v.opened.Value == false then
  4. v.opened.Value = true
  5. v.SurfaceGui.TextBox.Text = v.amount.Value
  6. v.CFrame = v.CFrame * CFrame.new(0,-.2,0)
  7. if v.amount.Value == "" then
  8. openupalot(model,v)
  9. end
  10. end
  11. end
  12. end
  13.  
  14. setup = function(player)
  15. player.Chatted:connect(function(msg)
  16. if msg == "/min" then
  17. local head = player.Character:FindFirstChild("Head")
  18. local size = 24
  19. local mines = 99
  20. local minesleft = mines
  21. if head then
  22. local start = CFrame.new(head.CFrame.X, 0, head.CFrame.Z)
  23. local tiles = {}
  24. start = start * CFrame.new(-size,0,-size)
  25. local mod = Instance.new("Model",workspace)
  26. mod.Name = player.Name.."'s minesweeper"
  27. for x = 1,size do
  28. for z = 1,size do
  29. local p = Instance.new("Part",mod)
  30. p.Anchored = true
  31. p.Locked = true
  32. p.Size = Vector3.new(2,1,2)
  33. p.CFrame = start * CFrame.new(x*2,0,z*2)
  34. p.Massless = true
  35. p.CanCollide = false
  36. local surfg = Instance.new("SurfaceGui",p)
  37. surfg.Face = "Top"
  38. surfg.CanvasSize = Vector2.new(150,150)
  39. local text = Instance.new("TextBox",surfg)
  40. text.Size = UDim2.new(1,0,1,0)
  41. text.TextScaled = true
  42. text.Text = ""
  43. text.Font = "Arcade"
  44. local var = Instance.new("BoolValue",p)
  45. var.Name = "flag"
  46. local var = Instance.new("BoolValue",p)
  47. var.Name = "opened"
  48. local var = Instance.new("BoolValue",p)
  49. var.Name = "bomb"
  50. local var = Instance.new("StringValue",p)
  51. var.Name = "amount"
  52. local clickd = Instance.new("ClickDetector",p)
  53. clickd.MouseClick:connect(function(play)
  54. if play == player and p.opened.Value == false and p.flag.Value == false then
  55. if p.bomb.Value == true then
  56. for i, v in pairs(mod:GetChildren()) do
  57. v.SurfaceGui:Destroy()
  58. v.BrickColor = BrickColor.Red()
  59. v.Material = Enum.Material.SmoothPlastic
  60. end
  61. local s = Instance.new("Sound",head)
  62. s.SoundId = "rbxassetid://2979857617"
  63. s.PlayOnRemove = true
  64. s.Volume = 2
  65. s:Destroy()
  66. for i, v in pairs(mod:GetChildren()) do
  67. v.Anchored = false
  68. v.Velocity = Vector3.new(math.random(-20,20),math.random(50,100),math.random(-20,20))
  69. v.RotVelocity = Vector3.new(math.random(-20,20),math.random(-20,20),math.random(-20,20))
  70. if i%size == 0 then
  71. wait(.2)
  72. end
  73. end
  74. end
  75. p.CFrame = p.CFrame * CFrame.new(0,-.2,0)
  76. p.opened.Value = true
  77. text.Text = p.amount.Value
  78. if p.amount.Value == "" then
  79. openupalot(mod,p)
  80. end
  81. text.TextColor3 = Color3.new(0,0,0)
  82. end
  83. end)
  84. clickd.RightMouseClick:connect(function(play)
  85. if play == player and p.opened.Value == false then
  86. if p.flag.Value == false then
  87. text.Text = "X"
  88. p.flag.Value = true
  89. text.TextColor3 = Color3.new(1,0,0)
  90. if p.bomb.Value == true then
  91. minesleft = minesleft - 1
  92. if minesleft == 0 then
  93. for i, v in pairs(mod:GetChildren()) do
  94. v.SurfaceGui:Destroy()
  95. v.BrickColor = BrickColor.Green()
  96. v.Material = Enum.Material.SmoothPlastic
  97. end
  98. local s = Instance.new("Sound",head)
  99. s.SoundId = "rbxassetid://934626738"
  100. s.PlayOnRemove = true
  101. s.Volume = 2
  102. s:Destroy()
  103. for i, v in pairs(mod:GetChildren()) do
  104. v.Anchored = false
  105. v.Velocity = Vector3.new(math.random(-20,20),math.random(50,100),math.random(-20,20))
  106. v.RotVelocity = Vector3.new(math.random(-20,20),math.random(-20,20),math.random(-20,20))
  107. if i%size == 0 then
  108. wait(.1)
  109. end
  110. end
  111. end
  112. end
  113. else
  114. text.Text = ""
  115. p.flag.Value = false
  116. text.TextColor3 = Color3.new(0,0,0)
  117. if p.bomb.Value == true then
  118. minesleft = minesleft + 1
  119. end
  120. end
  121. end
  122. end)
  123. tiles[#tiles+1] = p
  124. end
  125. end
  126. while mines > 0 do
  127. local tile = tiles[math.random(1,#tiles)]
  128. if tile.bomb.Value == false then
  129. tile.bomb.Value = true
  130. tile.SurfaceGui.TextBox.Text = ""
  131. mines = mines - 1
  132. end
  133. end
  134. for i, v in pairs(mod:GetChildren()) do
  135. if v.bomb.Value == false then
  136. local amount = 0
  137. for i, v2 in pairs(mod:GetChildren()) do
  138. if v ~= v2 then
  139. if (v.Position-v2.Position).Magnitude < 3 and v2.bomb.Value == true then
  140. amount = amount + 1
  141. end
  142. end
  143. end
  144. if amount > 0 then
  145. v.amount.Value = amount
  146. end
  147. end
  148. end
  149. end
  150. end
  151. end)
  152. end
  153.  
  154.  
  155. for i, v in pairs(game.Players:GetChildren()) do setup(v) end
  156. game.Players.PlayerAdded:Connect(function(v) setup(v) end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement