-- SERVIÇOS local Players = game:GetService("Players") local player = Players.LocalPlayer -- CONFIG local CELL_SIZE = 6 local CELL_HEIGHT = 0.15 local MINE_CHANCE = 0.18 -- ESTADO local pointA, pointB local fieldFolder = Instance.new("Folder", workspace) fieldFolder.Name = "CampoMinado_" .. player.Name -- GUI local gui = Instance.new("ScreenGui", player.PlayerGui) gui.Name = "CampoMinadoGUI" -- BOTÃO TOGGLE (DIREITA) local toggleBtn = Instance.new("TextButton", gui) toggleBtn.Size = UDim2.fromScale(0.05,0.08) toggleBtn.Position = UDim2.fromScale(0.93,0.45) toggleBtn.Text = "☰" toggleBtn.ZIndex = 2 -- PAINEL (ABRE PARA ESQUERDA) local panel = Instance.new("Frame", gui) panel.Size = UDim2.fromScale(0.2,0.35) panel.Position = UDim2.fromScale(0.72,0.35) panel.Visible = true panel.ZIndex = 1 local function makeBtn(txt, y) local b = Instance.new("TextButton", panel) b.Size = UDim2.fromScale(1,0.25) b.Position = UDim2.fromScale(0,y) b.Text = txt return b end local btnA = makeBtn("Marcar A",0) local btnB = makeBtn("Marcar B",0.25) local btnStart = makeBtn("Iniciar",0.5) local btnClose = makeBtn("Fechar",0.75) toggleBtn.MouseButton1Click:Connect(function() panel.Visible = not panel.Visible end) btnClose.MouseButton1Click:Connect(function() panel.Visible = false end) -- FUNÇÕES VISUAIS local function addBorders(cell) local t = 0.18 local h = 0.02 local s = cell.Size local borders = { {Vector3.new(s.X, t, t), Vector3.new(0, h, s.Z/2)}, {Vector3.new(s.X, t, t), Vector3.new(0, h, -s.Z/2)}, {Vector3.new(t, t, s.Z), Vector3.new(s.X/2, h, 0)}, {Vector3.new(t, t, s.Z), Vector3.new(-s.X/2, h, 0)}, } for _,data in ipairs(borders) do local b = Instance.new("Part") b.Size = data[1] b.Position = cell.Position + data[2] b.Anchored = true b.Color = Color3.fromRGB(0,0,0) b.Material = Enum.Material.SmoothPlastic b.CastShadow = false b.Parent = cell end end local function showNumber(cell) if cell:GetAttribute("Revealed") then return end cell:SetAttribute("Revealed", true) local n = cell:GetAttribute("Number") if n == 0 then return end local gui = Instance.new("BillboardGui", cell) gui.Size = UDim2.fromScale(2,2) gui.StudsOffset = Vector3.new(0,0.4,0) gui.AlwaysOnTop = true local txt = Instance.new("TextLabel", gui) txt.Size = UDim2.fromScale(1,1) txt.BackgroundTransparency = 1 txt.TextScaled = true txt.Text = tostring(n) txt.TextColor3 = Color3.new(0,0,0) txt.Font = Enum.Font.SourceSansBold end -- MARCAÇÃO btnA.MouseButton1Click:Connect(function() pointA = player.Character.HumanoidRootPart.Position end) btnB.MouseButton1Click:Connect(function() pointB = player.Character.HumanoidRootPart.Position end) -- CAMPO btnStart.MouseButton1Click:Connect(function() if not pointA or not pointB then return end fieldFolder:ClearAllChildren() local baseY = player.Character.HumanoidRootPart.Position.Y - 2.8 local minX = math.min(pointA.X, pointB.X) local maxX = math.max(pointA.X, pointB.X) local minZ = math.min(pointA.Z, pointB.Z) local maxZ = math.max(pointA.Z, pointB.Z) local grid = {} for x = minX, maxX, CELL_SIZE do for z = minZ, maxZ, CELL_SIZE do local cell = Instance.new("Part") cell.Size = Vector3.new(CELL_SIZE, CELL_HEIGHT, CELL_SIZE) cell.Position = Vector3.new(x, baseY + CELL_HEIGHT/2, z) cell.Anchored = true cell.Color = Color3.fromRGB(245,220,200) cell.Material = Enum.Material.SmoothPlastic cell.Transparency = 0.05 cell.Parent = fieldFolder addBorders(cell) local isMine = math.random() < MINE_CHANCE cell:SetAttribute("Mine", isMine) cell:SetAttribute("Revealed", false) table.insert(grid, cell) end end for _,cell in pairs(grid) do if not cell:GetAttribute("Mine") then local count = 0 for _,other in pairs(grid) do if other:GetAttribute("Mine") then if (cell.Position - other.Position).Magnitude <= CELL_SIZE*1.5 then count += 1 end end end cell:SetAttribute("Number", count) end cell.Touched:Connect(function(hit) local char = player.Character if not char then return end if hit.Parent ~= char then return end local hum = char:FindFirstChild("Humanoid") if not hum then return end if cell:GetAttribute("Mine") then hum.Health = 0 cell:Destroy() else showNumber(cell) end end) end end)