Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How does Handle dragging work? (mouse movement to 3D coordinates)

I'm working on a part placement tool, like many building games have. Moving the object through X and Z axis is fine, as long as there is some baseplate to be detected by mouse.Hit.

When it comes to Y axis, I wanted to make a system that locks the object position in X and Z, so I can control its height (like RCT building controls, if anyone remembers those).

The problem is that I don't know how to transform mouse movement into precise 3D coordinates. The closest thing that works like that is the dragging system of Handles, but I don't want to use them. Instead, I'd like to know how do they work, so I can make my own. Does anyone know how they work? Is it built-in or it uses regular Roblox API?

1 comment

1 answer

--local script
local player=game.Players.LocalPlayer
local mouse=player:GetMouse()
local runservice=game:GetService("RunService")
local p=workspace.Part --example
mouse.TargetFilter=p

runservice.RenderStepped:Connect(function()
       p.Position=mouse.Hit.p
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.