--!nocheck -- Voxel Mini-Minecraft (Ultimate Edition - Clean & Fixed) -- Сделал: https://scriptblox.com/u/nopls и deepseek if getgenv().VoxelMini_Cleanup then pcall(getgenv().VoxelMini_Cleanup) getgenv().VoxelMini_Cleanup = nil end local Players = game:GetService("Players") local UIS = game:GetService("UserInputService") local RS = game:GetService("RunService") local WS = game:GetService("Workspace") local TweenService = game:GetService("TweenService") local StarterGui = game:GetService("StarterGui") -- Отключаем стандартный рюкзак, чтобы он не перехватывал клавишу E pcall(function() StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false) StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false) end) local lp = Players.LocalPlayer local cam = WS.CurrentCamera local pg = lp:WaitForChild("PlayerGui") local BLOCK_SIZE = 4 local REACH = 500 -- ============ ЭКРАН ЗАГРУЗКИ ============ local loadGui = Instance.new("ScreenGui") loadGui.Name = "VoxelLoading" loadGui.IgnoreGuiInset = true loadGui.DisplayOrder = 999 loadGui.Parent = pg local loadBg = Instance.new("Frame") loadBg.Size = UDim2.fromScale(1, 1) loadBg.BackgroundColor3 = Color3.fromRGB(20, 20, 20) loadBg.BorderSizePixel = 0 loadBg.Parent = loadGui local loadText = Instance.new("TextLabel") loadText.Size = UDim2.fromScale(1, 1) loadText.BackgroundTransparency = 1 loadText.Font = Enum.Font.Arcade loadText.TextSize = 30 loadText.TextColor3 = Color3.fromRGB(255, 255, 255) loadText.Text = "Загрузка мира..." loadText.Parent = loadBg task.wait(1.5) loadText.Text = "Сделал:\nhttps://scriptblox.com/u/nopls\nи deepseek" task.wait(2.5) TweenService:Create(loadBg, TweenInfo.new(1), {BackgroundTransparency = 1}):Play() TweenService:Create(loadText, TweenInfo.new(1), {TextTransparency = 1}):Play() task.wait(1) loadGui:Destroy() -- ============ ГЕНЕРАЦИЯ ВСЕХ ПРЕДМЕТОВ ============ local ITEMS = {} local itemIndex = {} local function addItem(name, color, mat, kind, damage) table.insert(ITEMS, {name=name, color=color, mat=mat, kind=kind or "block", damage=damage or 0}) itemIndex[name] = #ITEMS end -- Базовые блоки local baseBlocks = { {"Grass", Color3.fromRGB(95, 159, 53), Enum.Material.Grass}, {"Dirt", Color3.fromRGB(134, 96, 67), Enum.Material.Ground}, {"Stone", Color3.fromRGB(125, 125, 125), Enum.Material.Slate}, {"Cobblestone", Color3.fromRGB(130, 130, 130), Enum.Material.Cobblestone}, {"Bedrock", Color3.fromRGB(30, 30, 30), Enum.Material.Slate}, {"Sand", Color3.fromRGB(219, 207, 163), Enum.Material.Sand}, {"Gravel", Color3.fromRGB(136, 126, 126), Enum.Material.Sand}, {"Glass", Color3.fromRGB(200, 220, 230), Enum.Material.Glass}, {"Obsidian", Color3.fromRGB(20, 18, 29), Enum.Material.Slate}, {"Netherrack", Color3.fromRGB(111, 54, 52), Enum.Material.Slate}, {"TNT", Color3.fromRGB(200, 40, 40), Enum.Material.SmoothPlastic}, {"Deepslate", Color3.fromRGB(80, 80, 80), Enum.Material.Slate}, {"End Stone", Color3.fromRGB(220, 220, 160), Enum.Material.Sand}, {"Soul Sand", Color3.fromRGB(80, 60, 50), Enum.Material.Sand} } for _, b in ipairs(baseBlocks) do addItem(b[1], b[2], b[3]) end -- Дерево local logs = {"Oak", "Spruce", "Birch", "Jungle", "Acacia", "Dark Oak", "Mangrove", "Cherry"} local woodColors = {Color3.fromRGB(109, 85, 50), Color3.fromRGB(58, 37, 16), Color3.fromRGB(216, 215, 210), Color3.fromRGB(85, 67, 25), Color3.fromRGB(103, 96, 86), Color3.fromRGB(60, 46, 26), Color3.fromRGB(90, 50, 30), Color3.fromRGB(230, 150, 180)} for i, name in ipairs(logs) do addItem(name.." Log", woodColors[i], Enum.Material.Wood) addItem(name.." Planks", woodColors[i]:Lerp(Color3.new(1,1,1), 0.3), Enum.Material.WoodPlanks) end -- Руда local ores = {"Coal", "Iron", "Gold", "Diamond", "Redstone", "Lapis", "Emerald", "Copper"} local oreColors = {Color3.fromRGB(40,40,40), Color3.fromRGB(200,180,160), Color3.fromRGB(250,238,77), Color3.fromRGB(98,237,228), Color3.fromRGB(255,50,50), Color3.fromRGB(50,80,200), Color3.fromRGB(42,203,88), Color3.fromRGB(210,120,70)} for i, ore in ipairs(ores) do addItem(ore.." Ore", oreColors[i], Enum.Material.Slate) addItem(ore.." Block", oreColors[i], Enum.Material.Metal) end -- Цветные блоки local colors = { {230, 230, 230}, {240, 118, 19}, {189, 68, 179}, {58, 175, 217}, {248, 198, 39}, {112, 185, 25}, {237, 141, 172}, {62, 68, 71}, {142, 142, 134}, {21, 137, 145}, {121, 42, 172}, {53, 57, 157}, {114, 71, 40}, {84, 109, 27}, {161, 39, 34}, {20, 21, 25} } for i, c in ipairs(colors) do local col = Color3.fromRGB(c[1], c[2], c[3]) addItem("Wool "..i, col, Enum.Material.Fabric) addItem("Concrete "..i, col, Enum.Material.Concrete) addItem("Terracotta "..i, col:Lerp(Color3.new(0.6,0.4,0.3), 0.4), Enum.Material.Brick) end -- МЕЧИ addItem("Wooden Sword", Color3.fromRGB(150, 105, 60), Enum.Material.Wood, "sword", 10) addItem("Stone Sword", Color3.fromRGB(125, 125, 125), Enum.Material.Slate, "sword", 20) addItem("Iron Sword", Color3.fromRGB(220, 220, 220), Enum.Material.Metal, "sword", 35) addItem("Diamond Sword", Color3.fromRGB(98, 237, 228), Enum.Material.Glass, "sword", 50) -- Стартовый хотбар local hotbarInv = { itemIndex["Diamond Sword"], itemIndex["TNT"], itemIndex["Grass"], itemIndex["Stone"], itemIndex["Oak Log"], itemIndex["Oak Planks"], itemIndex["Glass"], itemIndex["Cobblestone"], itemIndex["Sand"] } -- ============ МИР И МАТЕМАТИКА ============ local conns, instances = {}, {} local function track(c) table.insert(conns, c); return c end local function keep(i) table.insert(instances, i); return i end local world = keep(Instance.new("Folder")) world.Name = "VoxelWorld" world.Parent = WS local mobsFolder = keep(Instance.new("Folder")) mobsFolder.Name = "VoxelMobs" mobsFolder.Parent = WS local function snapToGrid(pos) local half = BLOCK_SIZE / 2 return Vector3.new( math.floor((pos.X - half) / BLOCK_SIZE + 0.5) * BLOCK_SIZE + half, math.floor((pos.Y - half) / BLOCK_SIZE + 0.5) * BLOCK_SIZE + half, math.floor((pos.Z - half) / BLOCK_SIZE + 0.5) * BLOCK_SIZE + half ) end local grid = {} local function keyOf(pos) local half = BLOCK_SIZE / 2 local gx = math.floor((pos.X - half) / BLOCK_SIZE + 0.5) local gy = math.floor((pos.Y - half) / BLOCK_SIZE + 0.5) local gz = math.floor((pos.Z - half) / BLOCK_SIZE + 0.5) return string.format("%d_%d_%d", gx, gy, gz) end for xi = -15, 14 do for zi = -15, 14 do local p = Instance.new("Part") p.Size = Vector3.new(BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE) p.Position = Vector3.new(xi * BLOCK_SIZE + BLOCK_SIZE/2, -BLOCK_SIZE/2, zi * BLOCK_SIZE + BLOCK_SIZE/2) p.Anchored = true p.Color = ITEMS[1].color p.Material = ITEMS[1].mat p.Parent = world grid[keyOf(p.Position)] = p end end local ghost = keep(Instance.new("Part")) ghost.Name = "GhostPreview" ghost.Size = Vector3.new(BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE) ghost.Anchored = true ghost.CanCollide = false ghost.CanQuery = false ghost.CanTouch = false ghost.Transparency = 1 ghost.Material = Enum.Material.SmoothPlastic ghost.Parent = WS local box = keep(Instance.new("SelectionBox")) box.Adornee = ghost box.LineThickness = 0.04 box.Color3 = Color3.new(0, 0, 0) box.Parent = WS local rayParams = RaycastParams.new() rayParams.FilterType = Enum.RaycastFilterType.Exclude rayParams.FilterDescendantsInstances = {ghost} -- ============ UI УТИЛИТЫ И 3D-ИКОНКИ ============ local function createSlot(parent, size, pos) local f = keep(Instance.new("Frame")) f.Size = size f.Position = pos f.BackgroundColor3 = Color3.fromRGB(139, 139, 139) f.BorderSizePixel = 2 f.BorderColor3 = Color3.fromRGB(55, 55, 55) f.ClipsDescendants = true f.ZIndex = 1 -- Базовый слой для ячейки f.Parent = parent local stroke = keep(Instance.new("UIStroke")) stroke.Color = Color3.fromRGB(255, 255, 255) stroke.Thickness = 1 stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border stroke.Parent = f return f end local function create3DIcon(parent, itemId) -- Очищаем старые иконки for _, child in ipairs(parent:GetChildren()) do if child.Name == "3DIcon" or child.Name == "FlatIcon" then child:Destroy() end end if not itemId then return end local b = ITEMS[itemId] -- 1. Подложка (на случай если 3D не прогрузится, будет виден цвет) local ic = Instance.new("Frame") ic.Name = "FlatIcon" ic.Size = UDim2.fromScale(0.8, 0.8) ic.Position = UDim2.fromScale(0.1, 0.1) ic.BackgroundColor3 = b.color ic.BorderSizePixel = 0 ic.ZIndex = 2 ic.Active = false ic.Parent = parent -- Ограничиваем 3D-рендер для экономии производительности if itemId > 150 and b.kind ~= "sword" then return end -- 2. 3D-модель поверх подложки local vp = Instance.new("ViewportFrame") vp.Name = "3DIcon" vp.Size = UDim2.fromScale(1, 1) vp.BackgroundTransparency = 1 vp.Ambient = Color3.fromRGB(255, 255, 255) -- Максимально яркий свет vp.LightColor = Color3.fromRGB(255, 255, 255) vp.ZIndex = 3 -- Поверх подложки vp.Active = false vp.Parent = parent local part = Instance.new("Part") part.Material = Enum.Material.SmoothPlastic -- Гарантирует отсутствие черных теней if b.kind == "sword" then part.Size = Vector3.new(0.4, 2.2, 0.2) else part.Size = Vector3.new(1.5, 1.5, 1.5) end part.Color = b.color part.Anchored = true part.Parent = vp local cam3d = Instance.new("Camera") cam3d.Parent = vp vp.CurrentCamera = cam3d if b.kind == "sword" then cam3d.CFrame = CFrame.new(Vector3.new(2, 2, 2), Vector3.new(0, 0, 0)) else cam3d.CFrame = CFrame.new(Vector3.new(3, 3, 3), Vector3.new(0, 0, 0)) end end local gui = keep(Instance.new("ScreenGui")) gui.Name = "MinecraftUI" gui.ResetOnSpawn = false gui.IgnoreGuiInset = true gui.DisplayOrder = 100 gui.Parent = pg -- ============ HUD ============ local hudFrame = keep(Instance.new("Frame")) hudFrame.Size = UDim2.fromOffset(450, 100) hudFrame.Position = UDim2.new(0.5, 0, 1, -120) hudFrame.AnchorPoint = Vector2.new(0.5, 1) hudFrame.BackgroundTransparency = 1 hudFrame.ZIndex = 10 hudFrame.Parent = gui local heartsFrame = keep(Instance.new("Frame")) heartsFrame.Size = UDim2.fromOffset(220, 20) heartsFrame.Position = UDim2.fromOffset(10, 10) heartsFrame.BackgroundTransparency = 1 heartsFrame.ZIndex = 11 heartsFrame.Parent = hudFrame local hearts = {} for i = 1, 10 do local heart = keep(Instance.new("TextLabel")) heart.Size = UDim2.fromOffset(20, 20) heart.Position = UDim2.fromOffset((i-1) * 22, 0) heart.BackgroundTransparency = 1 heart.Font = Enum.Font.Arcade heart.TextSize = 22 heart.TextColor3 = Color3.fromRGB(255, 30, 30) heart.TextStrokeTransparency = 0 heart.Text = "♥" heart.ZIndex = 12 heart.Parent = heartsFrame hearts[i] = heart end local hotbar = createSlot(hudFrame, UDim2.fromOffset(9 * 44 + 8, 52), UDim2.fromOffset(0, 35)) hotbar.BackgroundColor3 = Color3.fromRGB(198, 198, 198) hotbar.ZIndex = 11 local hotbarSlots = {} for i = 1, 9 do local slot = createSlot(hotbar, UDim2.fromOffset(40, 40), UDim2.fromOffset(4 + (i-1)*44, 6)) slot.ZIndex = 12 create3DIcon(slot, hotbarInv[i]) local num = keep(Instance.new("TextLabel")) num.Size = UDim2.fromOffset(12, 12) num.Position = UDim2.fromOffset(2, 2) num.BackgroundTransparency = 1 num.Font = Enum.Font.Arcade num.TextSize = 10 num.TextColor3 = Color3.new(1,1,1) num.TextStrokeTransparency = 0 num.Text = tostring(i) num.ZIndex = 15 num.Parent = slot hotbarSlots[i] = slot end -- ============ ИНВЕНТАРЬ ============ local invGui = keep(Instance.new("Frame")) invGui.Size = UDim2.fromOffset(620, 380) invGui.Position = UDim2.fromScale(0.5, 0.5) invGui.AnchorPoint = Vector2.new(0.5, 0.5) invGui.BackgroundColor3 = Color3.fromRGB(198, 198, 198) invGui.BorderSizePixel = 4 invGui.BorderColor3 = Color3.fromRGB(55, 55, 55) invGui.Visible = false invGui.ZIndex = 50 invGui.Parent = gui local tabBg = createSlot(invGui, UDim2.fromOffset(200, 30), UDim2.fromOffset(0, -32)) tabBg.ZIndex = 51 local tabTitle = keep(Instance.new("TextLabel")) tabTitle.Size = UDim2.fromScale(1,1) tabTitle.BackgroundTransparency = 1 tabTitle.Font = Enum.Font.Arcade tabTitle.TextSize = 14 tabTitle.TextColor3 = Color3.fromRGB(55,55,55) tabTitle.Text = "All Blocks & Items" tabTitle.ZIndex = 52 tabTitle.Parent = tabBg local closeBtn = createSlot(invGui, UDim2.fromOffset(30, 30), UDim2.new(1, -35, 0, -32)) closeBtn.BackgroundColor3 = Color3.fromRGB(200, 80, 80) closeBtn.ZIndex = 51 local closeLbl = keep(Instance.new("TextLabel")) closeLbl.Size = UDim2.fromScale(1,1) closeLbl.BackgroundTransparency = 1 closeLbl.Font = Enum.Font.Arcade closeLbl.TextSize = 18 closeLbl.TextColor3 = Color3.new(1,1,1) closeLbl.Text = "X" closeLbl.ZIndex = 52 closeLbl.Parent = closeBtn local leftPanel = createSlot(invGui, UDim2.fromOffset(300, 340), UDim2.fromOffset(10, 20)) leftPanel.BackgroundColor3 = Color3.fromRGB(160, 160, 160) leftPanel.ZIndex = 51 local scrollFrame = keep(Instance.new("ScrollingFrame")) scrollFrame.Size = UDim2.new(1, -10, 1, -10) scrollFrame.Position = UDim2.fromOffset(5, 5) scrollFrame.BackgroundTransparency = 1 scrollFrame.BorderSizePixel = 0 scrollFrame.ScrollBarThickness = 6 scrollFrame.AutomaticCanvasSize = Enum.AutomaticSize.Y scrollFrame.ZIndex = 52 scrollFrame.Parent = leftPanel local gridLayout = keep(Instance.new("UIGridLayout")) gridLayout.CellSize = UDim2.fromOffset(38, 38) gridLayout.CellPadding = UDim2.fromOffset(2, 2) gridLayout.SortOrder = Enum.SortOrder.LayoutOrder gridLayout.Parent = scrollFrame local selectedCraftItem = nil local craftSlots = {} local craftItems = {nil, nil, nil, nil} local outputSlot = nil local outputItem = nil -- ПРАВАЯ ПАНЕЛЬ local rightPanel = createSlot(invGui, UDim2.fromOffset(280, 340), UDim2.fromOffset(320, 20)) rightPanel.BackgroundColor3 = Color3.fromRGB(160, 160, 160) rightPanel.ZIndex = 51 local craftTitle = keep(Instance.new("TextLabel")) craftTitle.Size = UDim2.fromOffset(100, 20) craftTitle.Position = UDim2.fromOffset(90, 10) craftTitle.BackgroundTransparency = 1 craftTitle.Font = Enum.Font.Arcade craftTitle.TextSize = 14 craftTitle.TextColor3 = Color3.fromRGB(55,55,55) craftTitle.Text = "Crafting" craftTitle.ZIndex = 52 craftTitle.Parent = rightPanel local craftGrid = keep(Instance.new("Frame")) craftGrid.Size = UDim2.fromOffset(80, 80) craftGrid.Position = UDim2.fromOffset(30, 40) craftGrid.BackgroundTransparency = 1 craftGrid.ZIndex = 52 craftGrid.Parent = rightPanel for cx = 0, 1 do for cy = 0, 1 do local idx = cy * 2 + cx + 1 local cs = createSlot(craftGrid, UDim2.fromOffset(38, 38), UDim2.fromOffset(cx*40, cy*40)) cs.ZIndex = 53 craftSlots[idx] = cs local btn = keep(Instance.new("TextButton")) btn.Size = UDim2.fromScale(1,1) btn.BackgroundTransparency = 1 btn.Text = "" btn.ZIndex = 100 btn.Parent = cs track(btn.MouseButton1Click:Connect(function() if selectedCraftItem then craftItems[idx] = selectedCraftItem create3DIcon(cs, selectedCraftItem) checkRecipe() end end)) end end local arrow = keep(Instance.new("TextLabel")) arrow.Size = UDim2.fromOffset(30, 30) arrow.Position = UDim2.fromOffset(120, 65) arrow.BackgroundTransparency = 1 arrow.Font = Enum.Font.Arcade arrow.TextSize = 20 arrow.TextColor3 = Color3.fromRGB(55,55,55) arrow.Text = "=>" arrow.ZIndex = 52 arrow.Parent = rightPanel outputSlot = createSlot(rightPanel, UDim2.fromOffset(44, 44), UDim2.fromOffset(155, 58)) outputSlot.ZIndex = 53 local outBtn = keep(Instance.new("TextButton")) outBtn.Size = UDim2.fromScale(1,1) outBtn.BackgroundTransparency = 1 outBtn.Text = "" outBtn.ZIndex = 100 outBtn.Parent = outputSlot track(outBtn.MouseButton1Click:Connect(function() if outputItem then hotbarInv[selected] = outputItem create3DIcon(hotbarSlots[selected], outputItem) for i=1, 4 do craftItems[i] = nil for _, child in ipairs(craftSlots[i]:GetChildren()) do if child.Name == "3DIcon" or child.Name == "FlatIcon" then child:Destroy() end end end outputItem = nil for _, child in ipairs(outputSlot:GetChildren()) do if child.Name == "3DIcon" or child.Name == "FlatIcon" then child:Destroy() end end end end)) -- Кнопка спавна мобов local spawnMobBtn = createSlot(rightPanel, UDim2.fromOffset(120, 30), UDim2.fromOffset(80, 150)) spawnMobBtn.BackgroundColor3 = Color3.fromRGB(100, 200, 100) spawnMobBtn.ZIndex = 53 local smText = keep(Instance.new("TextLabel")) smText.Size = UDim2.fromScale(1,1) smText.BackgroundTransparency = 1 smText.Font = Enum.Font.Arcade smText.TextSize = 12 smText.TextColor3 = Color3.new(1,1,1) smText.Text = "Спавн моба (M)" smText.ZIndex = 54 smText.Parent = spawnMobBtn local smBtn = keep(Instance.new("TextButton")) smBtn.Size = UDim2.fromScale(1,1) smBtn.BackgroundTransparency = 1 smBtn.Text = "" smBtn.ZIndex = 100 smBtn.Parent = spawnMobBtn -- Сетка всех блоков for i, b in ipairs(ITEMS) do local s = createSlot(scrollFrame, UDim2.fromOffset(38, 38), UDim2.fromOffset(0,0)) s.LayoutOrder = i s.ZIndex = 53 create3DIcon(s, i) local btn = keep(Instance.new("TextButton")) btn.Size = UDim2.fromScale(1,1) btn.BackgroundTransparency = 1 btn.Text = "" btn.ZIndex = 100 -- Поверх 3D-иконки btn.Parent = s track(btn.MouseButton1Click:Connect(function() selectedCraftItem = i hotbarInv[selected] = i create3DIcon(hotbarSlots[selected], i) -- Подсветка выбранного блока for _, child in ipairs(scrollFrame:GetChildren()) do if child:IsA("Frame") then child.BorderColor3 = Color3.fromRGB(55,55,55) end end s.BorderColor3 = Color3.fromRGB(255, 255, 255) end)) end local function checkRecipe() local c = craftItems outputItem = nil for _, child in ipairs(outputSlot:GetChildren()) do if child.Name == "3DIcon" or child.Name == "FlatIcon" then child:Destroy() end end if not c[1] and not c[2] and not c[3] and not c[4] then return end local logId = itemIndex["Oak Log"] if c[1] == logId and c[2] == logId and c[3] == logId and c[4] == logId then outputItem = itemIndex["Oak Planks"] end if outputItem then create3DIcon(outputSlot, outputItem) end end track(closeBtn.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then invGui.Visible = false end end)) -- ============ ЛОГИКА ИГРОКА И МОБОВ ============ local selected = 1 local function updateSelection() for i, slot in ipairs(hotbarSlots) do slot.BorderSizePixel = (i == selected) and 3 or 2 slot.BorderColor3 = (i == selected) and Color3.new(1,1,1) or Color3.fromRGB(55,55,55) end end updateSelection() local function setSlot(n) selected = math.clamp(n, 1, 9) updateSelection() end local function updateHealth(hum) local ratio = hum.Health / math.max(hum.MaxHealth, 1) local fullHearts = math.floor(ratio * 10) for i = 1, 10 do hearts[i].TextTransparency = (i <= fullHearts) and 0 or 0.7 end end local function bindHealth(char) local hum = char:WaitForChild("Humanoid") track(hum.HealthChanged:Connect(function() updateHealth(hum) end)) updateHealth(hum) end if lp.Character then bindHealth(lp.Character) end track(lp.CharacterAdded:Connect(bindHealth)) -- Спавн мобов local function spawnMob() local char = lp.Character local hrp = char and char:FindFirstChild("HumanoidRootPart") if not hrp then return end local pos = hrp.Position + hrp.CFrame.LookVector * 10 + Vector3.new(0, 5, 0) local model = Instance.new("Model") model.Name = "Zombie" model.Parent = mobsFolder local head = Instance.new("Part") head.Size = Vector3.new(2,2,2) head.Color = Color3.fromRGB(50, 150, 50) head.Position = pos head.Parent = model local torso = Instance.new("Part") torso.Size = Vector3.new(2,2,1) torso.Color = Color3.fromRGB(50, 150, 50) torso.Position = pos - Vector3.new(0, 2, 0) torso.Parent = model local hum = Instance.new("Humanoid") hum.Parent = model model.PrimaryPart = torso local lastAttack = 0 local followConn = RS.Heartbeat:Connect(function() if not char or not char.Parent then followConn:Disconnect() return end local myHrp = char:FindFirstChild("HumanoidRootPart") if myHrp then local dir = (myHrp.Position - torso.Position).Unit torso.CFrame = CFrame.new(torso.Position + dir * 0.05, torso.Position + dir) head.Position = torso.Position + Vector3.new(0, 2, 0) if (torso.Position - myHrp.Position).Magnitude < 4 then if os.clock() - lastAttack > 2 then lastAttack = os.clock() local hp = char:FindFirstChild("Humanoid") if hp then hp.Health -= 1 end end end end end) track(followConn) end -- Взрыв TNT local function explodeTNT(pos) local boom = Instance.new("Part") boom.Size = Vector3.new(10,10,10) boom.Position = pos boom.Anchored = true boom.CanCollide = false boom.Transparency = 0.5 boom.Color = Color3.fromRGB(255, 100, 0) boom.Material = Enum.Material.Neon boom.Parent = WS game:GetService("Debris"):AddItem(boom, 0.2) for _, mob in ipairs(mobsFolder:GetChildren()) do local hrp = mob:FindFirstChild("HumanoidRootPart") if hrp and (hrp.Position - pos).Magnitude < 20 then local hp = mob:FindFirstChild("Humanoid") if hp then hp.Health = 0 end end end for key, part in pairs(grid) do if part and (part.Position - pos).Magnitude < 15 then grid[key] = nil part:Destroy() end end end -- Fly/Noclip local noclip = false local flyBV = nil local function toggleFly() noclip = not noclip local char = lp.Character local hrp = char and char:FindFirstChild("HumanoidRootPart") if noclip and hrp then flyBV = Instance.new("BodyVelocity") flyBV.Name = "FlyBV" flyBV.MaxForce = Vector3.new(1e5,1e5,1e5) flyBV.Velocity = Vector3.zero flyBV.Parent = hrp else if hrp then local old = hrp:FindFirstChild("FlyBV") if old then old:Destroy() end end end end track(RS.Stepped:Connect(function() if noclip and lp.Character then for _, v in ipairs(lp.Character:GetDescendants()) do if v:IsA("BasePart") then v.CanCollide = false end end end end)) track(RS.RenderStepped:Connect(function() if flyBV then local look = cam.CFrame.LookVector flyBV.Velocity = look * 60 end end)) -- ============ РЕЙКАСТ ============ local currentHit = nil local ghostPos = nil track(RS.RenderStepped:Connect(function() local filter = {ghost, mobsFolder} if lp.Character then table.insert(filter, lp.Character) end rayParams.FilterDescendantsInstances = filter local m = UIS:GetMouseLocation() local ray = cam:ScreenPointToRay(m.X, m.Y) local result = WS:Raycast(ray.Origin, ray.Direction * REACH, rayParams) local hitPos, hitNormal if result then currentHit = result local n = result.Normal local ax, ay, az = math.abs(n.X), math.abs(n.Y), math.abs(n.Z) if ax > ay and ax > az then n = Vector3.new(math.sign(n.X), 0, 0) elseif ay > ax and ay > az then n = Vector3.new(0, math.sign(n.Y), 0) else n = Vector3.new(0, 0, math.sign(n.Z)) end hitPos = result.Position hitNormal = n else currentHit = nil hitPos = ray.Origin + ray.Direction * 30 hitNormal = Vector3.new(0, 1, 0) end local targetPos = snapToGrid(hitPos + hitNormal * (BLOCK_SIZE / 2)) if not grid[keyOf(targetPos)] then local char = lp.Character local hrp = char and char:FindFirstChild("HumanoidRootPart") if hrp and (hrp.Position - targetPos).Magnitude < BLOCK_SIZE * 0.8 then ghostPos = nil ghost.Transparency = 1 box.Visible = false else ghostPos = targetPos ghost.Position = targetPos local b = ITEMS[hotbarInv[selected]] ghost.Color = b.color ghost.Material = b.mat ghost.Transparency = 0.4 box.Visible = (b.kind ~= "sword") end else ghostPos = nil ghost.Transparency = 1 box.Visible = false end end)) -- ============ ВВОД ============ track(UIS.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.One then setSlot(1) elseif input.KeyCode == Enum.KeyCode.Two then setSlot(2) elseif input.KeyCode == Enum.KeyCode.Three then setSlot(3) elseif input.KeyCode == Enum.KeyCode.Four then setSlot(4) elseif input.KeyCode == Enum.KeyCode.Five then setSlot(5) elseif input.KeyCode == Enum.KeyCode.Six then setSlot(6) elseif input.KeyCode == Enum.KeyCode.Seven then setSlot(7) elseif input.KeyCode == Enum.KeyCode.Eight then setSlot(8) elseif input.KeyCode == Enum.KeyCode.Nine then setSlot(9) elseif input.KeyCode == Enum.KeyCode.E then invGui.Visible = not invGui.Visible elseif input.KeyCode == Enum.KeyCode.F then toggleFly() elseif input.KeyCode == Enum.KeyCode.M then spawnMob() end if invGui.Visible then return end if input.UserInputType == Enum.UserInputType.MouseButton1 then if currentHit and currentHit.Instance then if currentHit.Instance.Parent == world then if currentHit.Instance.Name == "TNT" then explodeTNT(currentHit.Instance.Position) grid[keyOf(currentHit.Instance.Position)] = nil currentHit.Instance:Destroy() else grid[keyOf(currentHit.Instance.Position)] = nil currentHit.Instance:Destroy() end elseif currentHit.Instance.Parent == mobsFolder then local mob = currentHit.Instance.Parent local hp = mob:FindFirstChild("Humanoid") if hp then local b = ITEMS[hotbarInv[selected]] local dmg = (b.kind == "sword") and b.damage or 10 hp.Health -= dmg if hp.Health <= 0 then mob:Destroy() end end end end elseif input.UserInputType == Enum.UserInputType.MouseButton2 then if ghostPos then local b = ITEMS[hotbarInv[selected]] if b.kind == "sword" then return end local p = Instance.new("Part") p.Name = b.name p.Size = Vector3.new(BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE) p.Position = ghostPos p.Anchored = true p.Color = b.color p.Material = b.mat p.Parent = world grid[keyOf(p.Position)] = p end end end)) track(smBtn.MouseButton1Click:Connect(spawnMob)) track(UIS.InputChanged:Connect(function(input, gameProcessed) if gameProcessed then return end if input.UserInputType ~= Enum.UserInputType.MouseWheel then return end if invGui.Visible then return end local d = input.Position.Z if d == 0 then return end setSlot(selected + (d > 0 and 1 or -1)) end)) -- ============ CLEANUP ============ getgenv().VoxelMini_Cleanup = function() for _, c in ipairs(conns) do pcall(function() c:Disconnect() end) end for _, i in ipairs(instances) do pcall(function() i:Destroy() end) end pcall(function() StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true) StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true) end) if lp.Character then local hrp = lp.Character:FindFirstChild("HumanoidRootPart") if hrp then local old = hrp:FindFirstChild("FlyBV") if old then old:Destroy() end for _, v in ipairs(lp.Character:GetDescendants()) do if v:IsA("BasePart") then v.CanCollide = true end end end end end print("[VoxelMini] Loaded. Нажми E для инвентаря.")