#Click and drag block moving erratically

1 messages · Page 1 of 1 (latest)

merry knoll
#

see what I mean in the video, im new to scripting and have no clue whats causing the jank movement, I think it's because it's interacting with itself but I wouldn't know how to fix that, anyone have any ideas?
heres the code:

local down = false
local UIS = game:GetService("UserInputService")
local dragpart = workspace.DragTask
local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Button1Down:Connect(function()
    down = true
end)

mouse.Button1Up:Connect(function()
    down = false
end)

mouse.Move:Connect(function()
        if down == true then
        dragpart.CFrame = CFrame.new(mouse.Hit.X, 0, mouse.Hit.Z)
    end
end)
gilded yoke
#

it does look like the mouse is detecting the part

#

You can just add the part to a folder

#

then set the folder to the mouse ignore

#
local Mouse = game.Players.LocalPlayer:GetMouse()
local folderToFilter = workspace:WaitForChild("FolderToFilter") 
Mouse.TargetFilter = folderToFilter
queen helm
#

Also I recommend using UserInputService instead of Player:GetMouse()

queen helm
# merry knoll yea it's anchored

You might want to double check that nothing is changing its anchored state

Examining the video a bit more, it seems the part is being pushed out of the ground because its halfway clipped inside the baseplate

queen helm
merry knoll
#

it's 6 studs high

queen helm
#

So either something else is changing its position or its unanchored

merry knoll
#

give me a moment to do this first fix bcs I think that it might work

merry knoll
#

thanks man

#

and thanks @queen helm for the effort

#

think ur too good at coding for my problems 😭

gilded yoke
#

If that's all you are doing that is fine

#

but if you are doing something more complex, like creare said, raycasting would be the better option

merry knoll
#

I started a few days ago, that sounds a bit complex for me at the moment