Creating DragDetector "Grid Snapping"

I’m interested in making a drag system simlar to the one present in Work At A Pizza Place

I’ve been through the Devforum, looking for specific topics that may fit what I’m looking for but it seems that nobody else has had the same interests with DragDetectors, I’ve also been through “DragDetectors TestWorld 1 and 2” which came up with the following from TestWorld 2:

TestWorld Snapping Script
local ScriptableDragStyleExampleUtils = {}

local cachedHitPoint = Vector3.zero
local cachedHitNormal = Vector3.yAxis

function ScriptableDragStyleExampleUtils.followTheCursor(cursorRay, dragDetector)
	-- intersect with scene, excluding the folder containing this object

	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {dragDetector.Parent}
	raycastParams.FilterType = Enum.RaycastFilterType.Exclude

	local hitPoint = Vector3.zero
	local hitNormal = Vector3.yAxis

	local raycastResult = workspace:Raycast(cursorRay.Origin, cursorRay.Direction, raycastParams)	
	if raycastResult then
		hitPoint = raycastResult.Position
		hitNormal = raycastResult.Normal.Unit
	else
		hitPoint = cachedHitPoint
		hitNormal = cachedHitNormal
		--		warn("No raycast result!")
	end

	cachedHitPoint = hitPoint
	cachedHitNormal = hitNormal

	local lookDir1 = hitNormal:Cross(Vector3.xAxis)
	local lookDir2 = hitNormal:Cross(Vector3.yAxis)
	local lookDir = if lookDir1.Magnitude > lookDir2.Magnitude then lookDir1.Unit else lookDir2.Unit
	return CFrame.lookAt(hitPoint, hitPoint + lookDir, hitNormal)
end

return ScriptableDragStyleExampleUtils

Which only results in the part’s upper face facing outward + the collision being weird, with my lack of math knowledge I can’t really edit this to be fit for what I’m trying to do.

Expected Results

1 - Expected Result
https://www.youtube.com/watch?v=CQ2DtqRlZGA

2 - Unwanted Result
https://www.youtube.com/watch?v=6O0sYoVktKE

Should I just be using objects like ClickDetector and implementing a custom drag or can the modern technologies of DragDetectors help me?

The unwanted results should apply an offset half of the size towards the direction away from the point at which the raycast hits. But I believe Work at a Pizza Place may either use the original Drag tool or it may use Roblox’s old utility module.

Old Drag Tool:
Create a HopperBin and set its BinType to “Grab”.

Old Roblox Utility Module:
I forget exactly where it is, I thought it had something to do with “RbxUtility” (which you can look up and find sources for), but I can’t find the original module model nor where the original drag function is. The old drag tool seems like the better option anyway though.

If I knew where I could find this I would likely mark it as a solution, but I can’t really find out where this is, I’ll see later.

I’m not sure what you mean by that.

You can either create a new one by either creating it manually in Studio:

  1. image

  2. image

  3. image

Or you can write a script to create it:

local hopperBin = Instance.new('HopperBin')
hopperBin.BinType = Enum.BinType.Grab
hopperBin.Parent = game:GetService('StarterPack')
hopperBin = nil

I’m aware of those, but those are I believe deprecated, I mean the “RbxUtility”.

After some further research into some old scripts, it seems that a Dragger is used within the old Stamper. This instance appears to act more like a service as you can’t change its parent.

(Though obviously you’ll have to update the server via remotes with either method.)

I believe the reason I was looking for a modern solution, was due to a post like this where an administrator has explained that “Drag” could be removed in the future.

I believed you meant that “RbxUtility” was a “Lua Source” to Drag, but I believe you just meant the service, I’m aware that the service exists, but the risk of removal is too high and I don’t think it would be validated for anything new.