Hello!
I want to make a build tool to build anything. Basically, my tool works well... However, the blocks that I want to put doesn't appear on the sides of other blocks. Exactly, when I hover the mouse, for example, on the side of a pillar, then when I press the left mouse button, the block appears on pillar's top, and not where my mouse is or not on the side of the pillar.
Here's my localscript inside my tool:
--- Services --- local rs = game:GetService("ReplicatedStorage") --- Modules --- local BlockModule = require(rs.BlockModule) local ImageModule = require(rs.ImageModule) local WeldModule = require(rs.WeldModule) --- Variables --- local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse() local tool = script.Parent local function round(number,increment) number = math.floor(number) number = number-(number%increment) return number end --- Actual Code --- tool.Equipped:Connect(function() local placement = rs.Blocks:FindFirstChild("Part"):Clone() placement.Anchored = true placement.Transparency = 0.5 placement.CanTouch = false mouse.TargetFilter = placement placementmodel = Instance.new("Model",workspace) placementmodel.Name = player.Name.."'s placement" placement.Parent = placementmodel placementmodel.PrimaryPart = placement movePlacement = game:GetService("RunService").Stepped:Connect(function() -- it makes placement of selected block follow player's mouse placementmodel:MoveTo(Vector3.new(round(mouse.Hit.Position.X,1),round(mouse.Hit.Position.Y,1),round(mouse.Hit.Position.Z,1))) end) onMouseClick = mouse.Button1Down:Connect(function() rs.Place:FireServer("Part", placementmodel.PrimaryPart.Position) end) end) tool.Unequipped:Connect(function() onMouseClick:Disconnect() movePlacement:Disconnect() placementmodel:Destroy() end)
I hope I explained my problem clearly.
when you do
movePlacement = game:GetService("RunService").Stepped:Connect(function() -- it makes placement of selected block follow player's mouse placementmodel:MoveTo(Vector3.new(round(mouse.Hit.Position.X,1),round(mouse.Hit.Position.Y,1),round(mouse.Hit.Position.Z,1))) end)
instead of
placementmodel:MoveTo(Vector3.new(round(mouse.Hit.Position.X,1),round(mouse.Hit.Position.Y,1),round(mouse.Hit.Position.Z,1)))
do
placementmodel:PivotTo(CFrame.new(Vector3.new(round(mouse.Hit.Position.X,1),round(mouse.Hit.Position.Y,1),round(mouse.Hit.Position.Z,1))))
this is because :MoveTo() uses physics slightly more, as the part you create (likely) has collisions on, it moves on top because it cant fit into the given placement, whereas :PivotTo() ignores physical properties and just moves it instantly, sorry if this isnt that clear though!
lmk if this works!