Hello again! You probably have seen me before. If not, welcome! Now today’s problem is about this thing. You move your cursor and a random brick pops up. It’s like build a boat’s building system but only cursor movement. There are a couple of problems I need to discuss.
The problem was when I was in - game moving my cursor the brick showed up (Good news) but bad news is it kept like going off screen and going into the ground. Here’s evidence:
See what I mean now?
script:
local player = game.Players.LocalPlayer
local workspacepart = game:GetService("Workspace")
local partsgo = Instance.new("Model",workspacepart)
partsgo.Name = "ModelParts"
local madepart = Instance.new("Part",partsgo)
madepart.Size = Vector3.new(3,3,3)
madepart.Name = (player.Name.." Part")
madepart.Anchored = true
local mouse = player:GetMouse()
while true do
wait()
madepart.CFrame = CFrame.new(mouse.Hit.x/1,mouse.Hit.y/1,mouse.Hit.z)
end
this is happening because mouse.Hit is moved onto the surface of the part and then the part gets moved onto the new mouse.Hit and this keeps on stacking which is why it goes of the screen. an easy fix to this is setting the TargetFilter property of the mouse to the part your moving so that mouse.Hit ignores it.
mouse.TargetFilter = madepart
if you want it to stop going in the ground you could add half of its y size to its cframe which just pops it up by half of its size.
The issues that are shown here are 2 things. Brick is in the ground can be fixed by Vector3 movement to the brick by half of its y size. This is the same for anything you build. Position is the very center of the object. The second issue I saw was the part going all the way to the camera. This could be fixed by destroying a part and making a new one before you get the Mouse.Hit location.