So ive been making my own building game for 1 - 3 weeks now. And i recently learn the basics of Object and World space… But i ran into a pretty annoying problem

Ive been lookng around and trying to fix this myself but sadly failed… So i decided to see if i can get some help here?

Anyways when i implemented them into my module code the models just start spinning like crazyyyyy.

Heres a quick video to give you a better understanding

Heres my current way of moving the model:

– // Convert to object space

```
local function Convert_Cf(Part, Pos, Grid) -- Part = Plot, Pos = Ray position, Grid = 4
local Object_Pos = Part.CFrame:ToObjectSpace(Pos)
local Cf = Calc_Cf(Object_Pos, Grid)
local World_Cf = Part.CFrame:ToWorldSpace(Cf)
return World_Cf
end
```

– // Code that calculates the CFrame

```
function Calc_Cf(Vector, Grid) -- Vector = Ray position, Grid = 4
return CFrame.new(
math.floor(Vector.X / Grid + 0.5) * Grid,
math.floor(Vector.Y / Grid + 0.5) * Grid,
math.floor(Vector.Z / Grid + 0.5) * Grid
)
end
```

– // Code that moves the model around

```
Move = Run.RenderStepped:Connect(function()
local P, S = ray(M, {Plr.Character, game.Workspace.Terrain}) -- P = Ray position, S = Surface normal
if P and S then
local SURFACE = P + (S * (Current_Obj.PrimaryPart.Size * .5))
local Rot = CFrame.Angles(math.rad(Current_Obj.PrimaryPart.Orientation.X),math.rad(Current_Obj.PrimaryPart.Orientation.Y),math.rad(Current_Obj.PrimaryPart.Orientation.Z))
local Cf = Convert_Cf(Plot.Parent.PLOT, CFrame.new(P + SURFACE), Grid)
Current_Obj:SetPrimaryPartCFrame(Cf * Rot)
end
end)
```