local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UIS = game:GetService("UserInputService") local lp = Players.LocalPlayer local mouse = lp:GetMouse() local camera = workspace.CurrentCamera -- 1. Create the Tool local tool = Instance.new("Tool") tool.Name = "Telekinesis" tool.RequiresHandle = false tool.Parent = lp.Backpack -- 2. Settings local targetPart = nil local att0, att1, ap, ao = nil, nil, nil, nil local currentDistance = 20 local throwPower = 1000 -- 3. Cleanup Function local function release() if att0 then att0:Destroy() att0 = nil end if att1 then att1:Destroy() att1 = nil end if ap then ap:Destroy() ap = nil end if ao then ao:Destroy() ao = nil end targetPart = nil end tool.Deactivated:Connect(release) tool.Activated:Connect(function() local target = mouse.Target if target and not target.Anchored and not target:IsDescendantOf(lp.Character) then targetPart = target -- Calculate initial distance based on where the part is right now currentDistance = (camera.CFrame.Position - target.Position).Magnitude -- Create Modern Physics Constraints att0 = Instance.new("Attachment", targetPart) att1 = Instance.new("Attachment", workspace.Terrain) ap = Instance.new("AlignPosition", targetPart) ap.Attachment0 = att0 ap.Attachment1 = att1 ap.MaxForce = math.huge ap.Responsiveness = 200 ao = Instance.new("AlignOrientation", targetPart) ao.Attachment0 = att0 ao.Attachment1 = att1 ao.MaxTorque = math.huge ao.Responsiveness = 200 -- Stable Cursor Tracking local loop loop = RunService.RenderStepped:Connect(function() if targetPart and att1 then -- This math ensures the part stays on the 3D line created by your mouse local ray = mouse.UnitRay local targetPos = ray.Origin + (ray.Direction * currentDistance) att1.Position = targetPos -- This keeps the part's rotation stable relative to the world att1.WorldOrientation = targetPart.Orientation else loop:Disconnect() end end) end end) -- 4. Controls (R = Closer, T = Farther, Y = Throw) UIS.InputBegan:Connect(function(input, gameProcessed) if gameProcessed or not targetPart then return end if input.KeyCode == Enum.KeyCode.R then currentDistance = math.max(currentDistance - 5, 5) elseif input.KeyCode == Enum.KeyCode.T then currentDistance = currentDistance + 10 elseif input.KeyCode == Enum.KeyCode.Y then -- Throws exactly where the mouse is pointing local throwDir = mouse.UnitRay.Direction local savedPart = targetPart release() savedPart.AssemblyLinearVelocity = throwDir * throwPower end end) print("Telekinesis Loaded. Hold Click to grab, R/T to adjust distance, Y to throw.")