✓ Accepted answer
Simple solution!
***Divide mouse position by grid, add 0.5, round either up or down, and mutiply by grid (after rounding)**. You should be using a LocalScript for this.
Example:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Part= workspace.Part
local PosX, PosY, PosZ
local function Round(GridSize)
PosX = math.floor(mouse.Hit.X / GridSize + 0.5) * GridSize
PosY = 0.5
PosZ = math.floor(mouse.Hit.Z / GridSize + 0.5) * GridSize
end
local function Movement()
mouse.TargetFilter = Part
Round(2)
Part.Position = Vector3.new(PosX, PosY, PosZ)
end
mouse.Move:Connect(Movement)
I KNOW I know that this is a year old but I just had to answer this. Hope this helps... if you see this.
3 comments
There are two options. You could either have it detect the mouse position which would check the nearest place for a tile, or you could have tiles and use mouse.Target.
Divide mouse pos by grid, add 0.5, round, and mutiply by grid (after rounding).
Made an answer even though this is a year old. LOL