Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do i make my placement grid more accurate?

Asked by 4 years ago

How do i make the placement more correct and accurate?

Heres my script so far:

Run.Stepped:Connect(function(plays)
    if builded ~= nil then
        if builded.Type.Value == "Wall" then
            local mag = math.huge

            local grid

            for i, v in pairs(game.Workspace.Grids:GetChildren()) do
                local magger = (player.Character.HumanoidRootPart.Position - v.Position).magnitude

                if magger < mag then
                    mag = magger

                    grid = v
                end
            end

            builded.CFrame = grid.CFrame * CFrame.new(0, 0, -10)

            builded.CFrame = builded.CFrame + Vector3.new(0, 2.84, 0)
        end
    end
end)

Heres a video of the result

https://gyazo.com/fbb783805eb280d6dffedae7f202fa3d

So how do i fix it?

thanks

0
Hmm... I am not to shure... SharkOwen_dev 69 — 4y

1 answer

Log in to vote
0
Answered by
compUcomp 417 Moderation Voter
4 years ago

The problem might be in the CFrame manipulation you do after you chose the grid point. Remove line 18 and replace line 9 with

local magger = (player.Character.HumanoidRootPart.CFrame * Vector3.new(0, 0, -10) - v.Position).Magnitude

0
My building is now gone, i check its properties and its Y value is repeatedly going up..? ChrisTheRobloxPlayYT 256 — 4y
0
That would be the fault of line 20. Remove that too. compUcomp 417 — 4y
Ad

Answer this question