- What do you want to achieve?
I want to add increment (I’m not sure if that’s what it’s called) to the “move” mode of my building system, like moving a part by one stud. I’m still new to movement handles and I can’t find a way to do it
Here’s the script:
(it’s a local script placed into a ScreenGui in the StarterGui, inside there’s also a ObjectValue named “Part” which I used for testing. Also the parts need to have a BoolValue inside called “CanMove” for them to work with the system)
local plr = game.Players.LocalPlayer
local m = plr:GetMouse()
m.Button1Down:Connect(function()
if m.Target:FindFirstChild("CanMove") then ----- can only use parts with a boolvalue inside called "CanMove"
script.Parent.Part.Value = m.Target
if script.Parent:FindFirstChild("handle") then
script.Parent.handle:Destroy()
end
local handle = Instance.new("Handles")
handle.Parent = script.Parent
handle.Style = "Movement"
handle.Name = "handle"
handle.Adornee = m.Target
local lastCFrame = nil
script.Parent.handle.MouseDrag:Connect(function(face,distance)
local Direction = script.Parent.Part.Value.CFrame:VectorToWorldSpace(Vector3.FromNormalId(face))
script.Parent.Part.Value.CFrame = lastCFrame + (Direction * distance)
end)
script.Parent.handle.MouseButton1Down:Connect(function()
lastCFrame = script.Parent.Part.Value.CFrame
end)
end
end)