Video of the problem
Now, the video ain’t capturing the glitch entirely. What’s really happening is the model is rapidly flashing, and moving between the 2 positions you can see in the video. Video ain’t capturing enough frames/second, so it looks like the part is just moving, but either way, you can see in the video the part ‘glitching’ between 2 positions, even though the mouse ain’t even moving.
Moves the model wherever the mouses position is
local renderStepped
renderStepped = runService.RenderStepped:Connect(function()
local cframe = placement:Calculate(
playersPlot.PrimaryPart,
wallClone,
mouse.Hit.p,
var.Rotation
)
wallClone:SetPrimaryPartCFrame(cframe)
end)
Placement module (used for position the model)
function placement:Calculate(basePart, model, position, rotation)
local cframe, size = baseSize:Calculate(basePart)
local modelSize = CFrame.fromEulerAnglesYXZ(
0,
rotation,
0
)*model.PrimaryPart.Size
modelSize = Vector3.new(
math.abs(
modelSize.x
),
math.abs(
modelSize.y
),
math.abs(
modelSize.z
)
)
local lpos = cframe:PointToObjectSpace(position)
local size2 = (
size - Vector2.new(
modelSize.x,
modelSize.z
)
)/2
local x = math.clamp(
lpos.x,
-size2.x,
size2.x
)
local y = math.clamp(
lpos.y,
-size2.y,
size2.y
)
local grid = var.Wall_Grid
if grid > 0 then
x = math.sign(x)*((math.abs(x) - math.abs(x)%grid) + (size2.x%grid))
y = math.sign(y)*((math.abs(y) - math.abs(y)%grid) + (size2.y%grid))
end
return cframe*CFrame.new(x, y, -modelSize.y/2)*CFrame.Angles(-math.pi/2, rotation, 0)
end
Added a print(mouse.Hit.p) and it’s printing a different number rapidly, even tho in that SS the mouse was not moving.