Yeah you dont use .Origin, you use mouse.Hit. (mouse.Origin is where the the mouse its at when it runs)
Anyway, I’ve already done that, what i want to achieve is this:
As you can see, it doesn’t intersect with the parts.
PLEASE NOTE: If this is for a tool, make sure the position of the part is being sent to the server every time the mouse is moved, otherwise it will not sync.
You can do this via a RemoteEvent. When the player moves their mouse (mousemove), call FireServer on the event with the new position of the part. (If a part is being dragged.)
And on the server, set the part’s position.
i.e.
LocalScript
local draggingPart = nil
mouse.Move:Connect(function()
if draggingPart then
remoteEvent:FireServer(mouse.Position, draggingPart)
end
end)
mouse.MouseButton1Down(function()
draggingPart = mouse.Target
end)
mouse.MouseButton1Up(function()
draggingPart = nil
end)
Dont worry, the way im doing my script doesnt even use the MouseButton1Up. This is the code
local function updateBlacklistFolder(object)
dragger:MouseUp()
for _, v in pairs(BlackListFolder:GetChildren()) do
v:Destroy()
end
local newObject = object:Clone()
newObject.Parent = BlackListFolder
local toReference = Instance.new("Part")
toReference.Parent = BlackListFolder
toReference.Name = "toReference"
dragger:MouseDown(toReference, Vector3.new(0, 0, 0), {toReference})
end
but it sayys dragger:MouseUp() cannot be casted unless mouseDown has. So how to check it its down?
local dragging = false
local function updateBlacklistFolder(object)
if dragging then dragger:MouseUp() dragging = false end
for _, v in pairs(BlackListFolder:GetChildren()) do
v:Destroy()
end
local newObject = object:Clone()
newObject.Parent = BlackListFolder
local toReference = Instance.new("Part")
toReference.Parent = BlackListFolder
toReference.Name = "toReference"
dragging = true
dragger:MouseDown(toReference, Vector3.new(0, 0, 0), {toReference})
end
ive done that just now… the position is not really changing tho
The folder was so i can have blacklist to use mouse.Hit honestly (which might not be that useful now) and was updated every time i wanted to change the part i wanted to move. The idea was placing a part there and move it with a bodyPosition. So what I’m trying to do is make the part being dragged and make the bodyposition follow it so it has a smooth movement.
Also, I want this to be local, not serversided
Move event is inacurrate, because if you move the character and not the mouse, the part will not change the position, i know this can help or not but it’s good to contribute.
That’s true, but connecting to renderstepped and firing an event every tick is quite wasteful. Mouse move only fires when the mouse is moved (a lot less than renderstepped).
Also your code above
does not work for me. As I move the part, it moves farther away from my mouse.