The code I wrote wont detect object placement collisions

if CanPlace then
				--print("Render Step should work")
				local Go = RunService.RenderStepped:Connect(function()
					local MouseRay = Mouse.UnitRay
					local CastRay =, MouseRay.Direction * 1000)
					local IgnoreList = {ClonedObject, Character, ClonedObject.Boundary, Object.Boundary}
					local Hit, Position = workspace:FindPartOnRayWithIgnoreList(CastRay, IgnoreList)
					if Hit and (HumRoot.Position).Magnitude < MaxDist then
						CanPlace = true
						CanPlace = false
					local Angles = CFrame.Angles(0, math.rad(Rot), 0)
					local NewCFrame =, Position.Y + 1.5, Position.Z)
					ClonedObject:SetPrimaryPartCFrame(NewCFrame * Angles)
					if Hit and Hit.Name == "Plot" and Hit.Name ~= "Boundary" then
						CanPlace = true
						ReallyCanPlace = true
						CanPlace = false
						ReallyCanPlace = false

Problem is image
I have no idea how to fix this. Spent last 5 hours trying to fix the script up and nothing seems to work. Any ideas?

If you’re trying to prevent bad placement, use BasePart:GetTouchingParts() to see if it’s colliding with something. Use mouse position for placing it and a forced Y axis if you don’t want it to float up on things.

If the model cannot collide, take a look at this workaround for it. I recommend using a hitbox part around the model for determining this if there isn’t one already.

1 Like