Handles Not Working as Intended

Hello everyone.
I am pretty new to the Handle Adornments, in fact, I just got to know that they existed! I wanted to try them out, so I did (or at least tried to).

The problem here is that the Model moves too much in the direction of the Mouse Drag and it keeps moving even when my mouse is off the arrows. I have tried dampening this by setting “distance” to 1 and even used debounce (which does not create the intended results). I also tried to add a MouseLeave() and MouseEnter() events to cancel the movement, but they don’t seem to work.

Please view this video for clarity:

Here is my Local Script code:

local handle = script.Parent:WaitForChild("Handles")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local smallBlock = workspace:WaitForChild("SmallBlock")
local block = workspace:WaitForChild("Block")
local connection
local debounce = false

handle.Adornee = smallBlock.PrimaryPart

local function dragged(direction, distance)
	
	if not debounce then
		
		debounce = true
		
		local n = Enum.NormalId
		local primary = smallBlock.PrimaryPart
		local x, y, z = primary.Position.X, primary.Position.Y, primary.Position.Z
		
		if direction == n.Top then
			
			smallBlock:MoveTo(Vector3.new(x, y + distance, z))
			
		elseif direction == n.Bottom then
			
			smallBlock:MoveTo(Vector3.new(x, y - distance, z))
			
		elseif direction == n.Back then
			
			smallBlock:MoveTo(Vector3.new(x, y, z + distance))
			
		elseif direction == n.Front then
			
			smallBlock:MoveTo(Vector3.new(x, y, z - distance))
			
		elseif direction == n.Left then
			
			smallBlock:MoveTo(Vector3.new(x - distance, y, z))
			
		elseif direction == n.Right then
			
			smallBlock:MoveTo(Vector3.new(x + distance, y, z))
			
		end
		
		wait()
		debounce = false
	
	end
	
end


handle.MouseEnter:Connect(function()

	connection = handle.MouseDrag:Connect(dragged)

end)

handle.MouseLeave:Connect(function()

	connection:Disconnect()

end)

Any help is appreciated.
Thank you.

1 Like

This sounds more like a scripting issue as there must be something wrong with the code. Try posting this in #development-support:scripting-support.

2 Likes