local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local LocalPlayer = Players.LocalPlayer local active = false local connection = nil local targetPart = nil local function getClosestPallet() local character = LocalPlayer.Character if not character then return nil end local rootPart = character:FindFirstChild("HumanoidRootPart") if not rootPart then return nil end local closestPart = nil local shortestDistance = math.huge for _, obj in pairs(game.Workspace:GetDescendants()) do if obj:IsA("BasePart") and (string.find(string.lower(obj.Name), "pallet") or (obj.Parent and string.find(string.lower(obj.Parent.Name), "pallet"))) then local distance = (rootPart.Position - obj.Position).Magnitude if distance < shortestDistance then shortestDistance = distance closestPart = obj end end end return closestPart end local function startLock() targetPart = getClosestPallet() if not targetPart then print("Failed: No Pallet found") active = false return end local character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() local rootPart = character:WaitForChild("HumanoidRootPart") local offset = Vector3.new(0, 3.5, 0) connection = RunService.Heartbeat:Connect(function() if active and character and character.Parent and targetPart and targetPart.Parent then rootPart.CFrame = targetPart.CFrame + offset rootPart.Velocity = Vector3.zero else if connection then connection:Disconnect() connection = nil end end end) print("Locked") end local function stopLock() active = false if connection then connection:Disconnect() connection = nil end targetPart = nil print("Unlocked") end UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.KeyCode == Enum.KeyCode.Z then active = not active if active then startLock() else stopLock() end end end)