I made a mouse move script which will move parts in your game.
Whenever I move the part it gets stuck in the ground.
Here’s my current code which moves the part and places it down with the mouse, I’m unsure how to make it not get stuck in the ground when I move it as you saw in the image above.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local mtarget
local down
function clickedOn()
mtarget = mouse.Target
mouse.TargetFilter = mtarget
down = true
end
mouse.Button1Down:Connect(clickedOn)
function mouseMove()
if down and mtarget then
local posX,posY,posZ = mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z
mtarget.Position = Vector3.new(posX,posY,posZ)
end
end
mouse.Move:Connect(mouseMove)
function mouseUp()
down = false
mtarget = nil
mouse.TargetFilter = nil
end
mouse.Button1Up:Connect(mouseUp)
-- This is an example Lua code block
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local mtarget
local down
function clickedOn()
mtarget = mouse.Target
mouse.TargetFilter = mtarget
down = true
end
mouse.Button1Down:Connect(clickedOn)
function mouseMove()
if down and mtarget then
local posX,posY,posZ = mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z
mtarget.Position = Vector3.new(posX,posY + (mtarget.Size.Y / 2),posZ)
end
end
mouse.Move:Connect(mouseMove)
function mouseUp()
down = false
mtarget = nil
mouse.TargetFilter = nil
end
mouse.Button1Up:Connect(mouseUp)