This is the script using Raycast and User Input Service with a range system
local UserInputService = game:GetService("UserInputService")
local Range = 10
local Folder = workspace -- Your block's folder
UserInputService.InputBegan:Connect(function(Input, Interact)
if not Interact and not game.Players.LocalPlayer.Character:FindFirstChild("pickaxe") and Input.UserInputType == Enum.UserInputType.MouseButton1 then
local ViewPoint, Param = workspace.CurrentCamera:ViewportPointToRay(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y), RaycastParams.new()
Param.FilterType, Param.FilterDescendantsInstances = Enum.RaycastFilterType.Include, {Folder}
local Raycast = workspace:Raycast(ViewPoint.Origin, ViewPoint.Direction * 10000, Param)
if (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - Raycast.Instance.Position).Magnitude <= Range then
--- Your script
print("A")
end
end
end)