Rotation Not Working as it Should

I recently followed a tutorial created by Egomoose where he showed people how to create a placement system. I’ve then modified it to be more like I imagine it to be like in my experience by switching the keyboard controls to visible buttons for compatibility with mobile. I got the place button to work but when I click the rotate button, the furniture rotates randomly. I’ll show you the rotate parts of the script and then record a video of it happening.

--ClientPlacement - LocalScript
local function onRotate(actionName, userInputState, input)
	rotation = rotation + math.pi/2

		local cf = placement:CalcPlacementCFrame(model, model.PrimaryPart.Position, rotation)


--Placement - ModuleScript - This one hasn't been edited but I'll put it in here so you can see it.
function Placement:CalcPlacementCFrame(model, position, rotation)
	local cf, size = self:CalcCanvas()

	local modelSize = CFrame.fromEulerAnglesYXZ(0, rotation, 0) * model.PrimaryPart.Size
	modelSize =, math.abs(modelSize.y), math.abs(modelSize.z))

	local lpos = cf:pointToObjectSpace(position);
	local size2 = (size -, modelSize.z))/2
	local x = math.clamp(lpos.x, -size2.x, size2.x);
	local y = math.clamp(lpos.y, -size2.y, size2.y);
	local g = self.GridUnit
	if (g > 0) then
		x = math.sign(x)*((math.abs(x) - math.abs(x) % g) + (size2.x % g))
		y = math.sign(y)*((math.abs(y) - math.abs(y) % g) + (size2.y % g))
	return cf *, y, -modelSize.y/2) * CFrame.Angles(-math.pi/2, rotation, 0)

Try removing renderstep, there is no need to continuously connect a connection.

Once connected it’ll listen until disconnected or script is destroyed.

Plus they can overlap.

1 Like

Ohh, that would make sense. I completely forgot that you wouldn’t need to call it again and again. Stupid mistake. :man_shrugging: