What's new
Heapleak - Scripthub

Get the most out of HeapLeak by creating a free account! Once signed in, you’ll gain full access to restricted content, be able to share your own scripts, and participate in our member-only discussions.

ADVANCED CUSTOMIZATION | Prehistoria! Crystal Farm

Version / Update: v1.0.0
Download / Script Link
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local player = Players.LocalPlayer

-- ===== Helpers =====
local function getHRP()
local char = player.Character or player.CharacterAdded:Wait()
return char:WaitForChild("HumanoidRootPart")
end

local function getTeleportPart(obj)
if obj:IsA("BasePart") then
return obj
elseif obj:IsA("Model") then
return obj.PrimaryPart or obj:FindFirstChildWhichIsA("BasePart", true)
else
return obj:FindFirstChildWhichIsA("BasePart", true)
end
end

local function isCrystal(inst)
return inst.Name:lower():find("crystal") ~= nil
end

local function findNearestCrystal()
local hrp = getHRP()
local nearestObj, nearestPart, best = nil, nil, math.huge

for _, inst in ipairs(workspace:GetDescendants()) do
if isCrystal(inst) then
local part = getTeleportPart(inst)
if part then
local d = (hrp.Position - part.Position).Magnitude
if d < best then
best = d
nearestObj = inst
nearestPart = part
end
end
end
end

return nearestObj, nearestPart, best
end

local function teleportToPart(part)
local hrp = getHRP()
hrp.CFrame = part.CFrame + Vector3.new(0, 5, 0)
end

-- ===== GUI =====
local gui = Instance.new("ScreenGui")
gui.Name = "CrystalAutoFarm"
gui.ResetOnSpawn = false
gui.Parent = player:WaitForChild("PlayerGui")

local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 340, 0, 170)
frame.Position = UDim2.new(0.5, -170, 0.7, 0)
frame.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
frame.BorderSizePixel = 0
frame.Parent = gui
Instance.new("UICorner", frame).CornerRadius = UDim.new(0, 12)

local title = Instance.new("TextLabel")
title.Size = UDim2.new(1, -20, 0, 26)
title.Position = UDim2.new(0, 10, 0, 8)
title.BackgroundTransparency = 1
title.Text = "Crystal Farmer Made By HUGEboss1 AKA Micky Mouse"
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamBold
title.TextSize = 16
title.TextXAlignment = Enum.TextXAlignment.Left
title.Parent = frame

local status = Instance.new("TextLabel")
status.Size = UDim2.new(1, -20, 0, 18)
status.Position = UDim2.new(0, 10, 0, 34)
status.BackgroundTransparency = 1
status.Text = "Status: OFF"
status.TextColor3 = Color3.fromRGB(220, 220, 220)
status.Font = Enum.Font.Gotham
status.TextSize = 12
status.TextXAlignment = Enum.TextXAlignment.Left
status.Parent = frame

local distLabel = Instance.new("TextLabel")
distLabel.Size = UDim2.new(1, -20, 0, 18)
distLabel.Position = UDim2.new(0, 10, 0, 52)
distLabel.BackgroundTransparency = 1
distLabel.Text = "Nearest: --"
distLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
distLabel.Font = Enum.Font.Gotham
distLabel.TextSize = 12
distLabel.TextXAlignment = Enum.TextXAlignment.Left
distLabel.Parent = frame

local autoBtn = Instance.new("TextButton")
autoBtn.Size = UDim2.new(1, -20, 0, 48)
autoBtn.Position = UDim2.new(0, 10, 0, 76)
autoBtn.BackgroundColor3 = Color3.fromRGB(70, 130, 255)
autoBtn.BorderSizePixel = 0
autoBtn.Text = "Start Auto Farm"
autoBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
autoBtn.Font = Enum.Font.GothamBold
autoBtn.TextSize = 18
autoBtn.Parent = frame
Instance.new("UICorner", autoBtn).CornerRadius = UDim.new(0, 10)

local tpOnceBtn = Instance.new("TextButton")
tpOnceBtn.Size = UDim2.new(1, -20, 0, 32)
tpOnceBtn.Position = UDim2.new(0, 10, 0, 130)
tpOnceBtn.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
tpOnceBtn.BorderSizePixel = 0
tpOnceBtn.Text = "Fix Teleport"
tpOnceBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
tpOnceBtn.Font = Enum.Font.Gotham
tpOnceBtn.TextSize = 14
tpOnceBtn.Parent = frame
Instance.new("UICorner", tpOnceBtn).CornerRadius = UDim.new(0, 8)

-- ===== Draggable frame =====
do
local dragging = false
local dragStart, startPos

frame.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = true
dragStart = input.Position
startPos = frame.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)

UserInputService.InputChanged:Connect(function(input)
if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
local delta = input.Position - dragStart
frame.Position = UDim2.new(
startPos.X.Scale, startPos.X.Offset + delta.X,
startPos.Y.Scale, startPos.Y.Offset + delta.Y
)
end
end)
end

-- ===== Autofarm logic =====
local running = false
local currentTargetObj = nil
local currentTargetPart = nil
local targetConn = nil

local function clearTargetWatcher()
if targetConn then
targetConn:Disconnect()
targetConn = nil
end
currentTargetObj = nil
currentTargetPart = nil
end

local function watchTargetGone(obj)
clearTargetWatcher()
currentTargetObj = obj

-- refresh when the current target disappears
targetConn = obj.AncestryChanged:Connect(function(_, parent)
if running and parent == nil then
status.Text = "Status: Target gone, next..."
task.defer(function()
local nObj, nPart = findNearestCrystal()
if nObj and nPart then
currentTargetObj = nObj
currentTargetPart = nPart
teleportToPart(nPart)
watchTargetGone(nObj)
else
status.Text = "Status: No crystals found"
clearTargetWatcher()
end
end)
end
end)
end

local function teleportToNearest()
local obj, part, dist = findNearestCrystal()
if obj and part then
distLabel.Text = ("Nearest: %.1f studs"):format(dist)
teleportToPart(part)
currentTargetPart = part
watchTargetGone(obj)
status.Text = "Status: Farming..."
else
status.Text = "Status: No crystals found"
distLabel.Text = "Nearest: --"
clearTargetWatcher()
end
end

local function updateButton()
if running then
autoBtn.Text = "Stop Auto Farm"
autoBtn.BackgroundColor3 = Color3.fromRGB(220, 80, 80)
status.Text = "Status: Farming..."
else
autoBtn.Text = "Start Auto Farm"
autoBtn.BackgroundColor3 = Color3.fromRGB(70, 130, 255)
status.Text = "Status: OFF"
end
end

autoBtn.MouseButton1Click:Connect(function()
running = not running
updateButton()

if running then
teleportToNearest()
else
clearTargetWatcher()
end
end)

tpOnceBtn.MouseButton1Click:Connect(function()
teleportToNearest()
end)

-- Update distance display while running
RunService.Heartbeat:Connect(function()
if not running then return end
local _, _, dist = findNearestCrystal()
if dist == math.huge then
distLabel.Text = "Nearest: --"
else
distLabel.Text = ("Nearest: %.1f studs"):format(dist)
end
end)

updateButton()
[ View More ]
de0d28b5-9d09-4146-88d2-94596d3e0ac6.webp


It teleports you to the nearest Crystal But you need to push E, I suggest Getting a Auto Hotkey to Push it you're self If it stops working Push "Fix Teleport" and it will tell you if there are no crystals Near by
 
Back
Top