Placing objects on their sides / vertical platforms

I’ve had a look through this thread Placement System For Wall Objects

and it’s kinda given me the basic idea, however not really

local renderStepped	
	renderStepped = runService.RenderStepped:Connect(function()
		if config.Base == 'Floor' then
			if mouse.Target.Name == 'Base' then
				playersPlot.PrimaryPart = mouse.Target
			end
			local cframe = placement(
				playersPlot.PrimaryPart,
				itemClone, 
				mouse.Hit.p, 
				var.Rotation
			)
			itemClone:SetPrimaryPartCFrame(cframe)
		else
			mouse.TargetFilter = itemClone
			local unitRay  = workspace.CurrentCamera:ScreenPointToRay(mouse.X, mouse.Y, 1)
			local ray = Ray.new(unitRay.Origin, unitRay.Direction * 1000)
			local hit, pos, normal = workspace:FindPartOnRay(ray, itemClone)
			itemClone:SetPrimaryPartCFrame(CFrame.new(pos, pos + normal*15))
		end
		
        -- Collision checker
		for _, v in pairs(getTouchingParts(itemClone.PrimaryPart)) do
			if not v:IsDescendantOf(itemClone) then
				itemClone.PrimaryPart.Transparency = 0.5	
				break			
			end
			itemClone.PrimaryPart.Transparency = 1
		end
	end)

So basically I have 2 sets of items. Floor and wall items. The floor items have their own placement code, and now I’m working on the stuff for placing wall items (like paintings, etc.)

Here are the problems I am facing:

  • The item being on moved along the floor when the mouse moves over it. The item should be restricted to walls only.
  • Rotating the doesn’t work. Inside the Floor based placing, var.Rotation, which is controlled like this
function onRotate(actionName, userInputState, input)
	if userInputState == Enum.UserInputState.Begin then
		var.Rotation = var.Rotation + math.pi/4 --/2 for 90 | /4 for 45
	end
end

contextActionService:BindAction('Rotate', onRotate, false, Enum.KeyCode.R)

Pressing R is definately firing the function, just not sure how to rotate the image with this.

  • Can’t place the item. Where I have the collision checker, the item is constantly saying it’s colliding with the wall. The Hitbox for the item is 0.1, so not sure if that’s why.
    Gif to explain some of the stuff better

com-video-to-gif

Kinda hard to see in the vid, but the part is like 0.05 studs into the wall, thus causing it to be colliding with it. Also the entire time I am clicking and pressing R to nothing.

1 Like