Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make my placement grid more accurate?

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

1 comment

0

Hmm... I am not to shure...

1 answer

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

2 comments

0

My building is now gone, i check its properties and its Y value is repeatedly going up..?

0

That would be the fault of line 20. Remove that too.

This discussion is preserved as it was. New answers, comments, and votes are closed.