Placing System, I have a few bugs when moving a object around with the mouse

Hello, I’m trying to make a placing system but I wanna get rid of these bugs before I go any further.

I’m able to get the object to follow my mouse but when I move the object around its Not Colliding with anything, its going through everything in the workspace.

as you see its not on the part, its going through it, how can I fix this?

local NewBedModel = game.ReplicatedStorage.BedModel1:Clone()
NewBedModel.Parent = workspace
			
RunService.RenderStepped:Connect(function()
				
      NewBedModel.PrimaryPart.CFrame = CFrame.new(math.floor(Mouse.Hit.X), MyPlot.Position.Y, math.floor(Mouse.Hit.Z))
			
end)

also other bug is when I move my mouse to the left side of the screen, its starts flicking the object back and fourth. (the mouse is in the same spot)

its video wasn’t loading so here is some images.

1 Like

Use SetPrimaryPartCFrame() instead

local NewBedModel = game.ReplicatedStorage.BedModel1:Clone()
NewBedModel.Parent = workspace
			
RunService.RenderStepped:Connect(function()
      local UsedCFrame = CFrame.new(math.floor(Mouse.Hit.X), MyPlot.Position.Y, math.floor(Mouse.Hit.Z))
      NewBedModel:SetPrimaryPartCFrame(UsedCFrame)
			
end)

This will set all parts within the model to position according to the new position of the PrimaryPart

Hope this helps!

I’m still having the same problem

I got it fixed, thanks for the help

FYI, :SetPrimaryPartCFrame() is now deprecated. :GetPivot() & :PivotTo() should now be used for model positioning-related stuff, isn’t even necessary to set a PrimaryPart.