I'm trying to get a part to follow my mouse on a grid, but it just feels... off... It does not feel like I'm doing the grid part correctly. I tried using both math.ceil and math.floor;
local camera = workspace.CurrentCamera;
local mouse = game.Players.LocalPlayer:GetMouse();
local previewItem = Instance.new("Part");
previewItem.Parent = game.Workspace;
previewItem.Size = Vector3.new(1, 1, 1);
mouse.Move:Connect(function()
local unitRay = camera:ScreenPointToRay(mouse.X, mouse.Y);
local ray = Ray.new(unitRay.Origin, unitRay.Direction * 500);
local part, pos = workspace:FindPartOnRayWithIgnoreList(ray, {game.Players.LocalPlayer.Character, previewItem});
if part then
previewItem.Position = Vector3.new(math.floor(pos.X / 5) * 5, math.floor(pos.Y / 5) * 5, math.floor(pos.Z / 5) * 5);
end;
end);
What am I doing wrong and how should I be doing it?
It follows my mouse perfectly without the grid code, the grid code is causing the issue.

3 comments
It's much better but it still doesn't quite feel right.
Then i'd suggest removing the division and multiplication part.
Thanks, it works really well now!