Hello.
I am trying to setup a placement system and constraint it to the base.
But when I try to clamp the model it works for 2 sides, but not for the other 2 sides.
It’s hard to explain, so watch this gif.
GIF
Fyi, I am using ZBlock’s Placement System.
This is what I currently have. (It’s in the placement module):
local function CalcualateNewPosition()
if MoveByGrid then
posX = math.clamp(math.floor((mouse.Hit.X / grid) + 0.5) * grid, workspace.Plots.Plot1.Canvas.Position.X - workspace.Plots.Plot1.Canvas.Size.X / 2, workspace.Plots.Plot1.Canvas.Position.X + workspace.Plots.Plot1.Canvas.Size.X/2)
posZ = math.clamp(math.floor((mouse.Hit.Z / grid) + 0.5) * grid, workspace.Plots.Plot1.Canvas.Position.Z - workspace.Plots.Plot1.Canvas.Size.Z / 2, workspace.Plots.Plot1.Canvas.Position.Z + workspace.Plots.Plot1.Canvas.Size.Z/2)
else
posX = mouse.Hit.X
posZ = mouse.Hit.Z
end
if EnableFloors and not stacking then
if posY > MaxHeight then
posY = MaxHeight
elseif posY < startingY then
posY = startingY
end
end
if stacking then
posY = math.floor(mouse.Hit.Y) + step
if posY > MaxHeight then
posY = MaxHeight
elseif posY < startingY then
posY = startingY
end
end
end
I have used the clamping method from here: Stop part going outside an area? - #10 by StrategicPlayZ
I have tried multiple times, but It has not worked.
I have looked on the developer forum but I have not found a answer that works.
Thanks in advance.