Trying to make a script that moves a part that exists in the workspace with the mouse but the mouse is like 5 studs away from the part, i want the mouse to be on the part so i can move the part around properly
Heres the script: localscript
local gridSize = 5
local pos = mouse.hit.p
local x = math.floor((pos.X/model.PrimaryPart.Size.X)+(gridSize/2))
local y = math.floor((pos.Y/model.PrimaryPart.Size.Y)+(gridSize/2))
local z = math.floor((pos.Z/model.PrimaryPart.Size.Z)+(gridSize/2))
pos = Vector3.new(x,y,z)
model.Parent = workspace
model:SetPrimaryPartCFrame(CFrame.new() + pos)

4 comments
I believe your math is wrong. Can you describe exactly what you're trying to accomplish? Explain as if I don't know what "grid placement system" means.
Trying to make a script that moves a part that exists in the workspace with the mouse but the mouse is like 5 studs away from the part, i want the mouse to be on the part so i can move the part around properly
is this the full script? What exactly is the "model" variable?
it is just local model = workspace.Model