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

How to Prevent Overlapping Whith Anchored On?

Hi Thanks for you Time And Efford I Appreciate it I Have a Grid System like Minicraft When a player Clicks a Part Will be Createt but these Parts Collide with each other and glitch because I have another on is there any solution to have anchored on and prevent overlapping my solution was to set anchored off and then wait 0.1 seconds so it pushes it out and then turn anchored on but that was not the smartest Solution here is the code

part.Anchored=false
wait(0.01)
part.Anchored=true

thank you.

6 comments

0

Please read the dev hub

0

thanks

0

Remove the instance if you dont want a new part

0

The whole line

0

then an error occurs attempt to index nil with 'Parent'

3 answers

Keep anchored on for all blocks at all times, and to avoid glitching you have to create a grid system by rounding input positions to the nearest unit of the block size. I'm not sure how your current grid system works due to a lack of code given, but it shouldn't have this problem if rounded correctly.

1 comment

0

I have postet the code below rekedev

here is my code rokedev

			local part=Instance.new("Part")	
			local cubeSize = 2.2	
			function convert(axis)
	    		return math.floor(axis / cubeSize) * cubeSize
			end
			local x,y,z = convert(mouseposx),convert(mouseposy),convert(mouseposz)
	 


			
			part.Parent=script.Parent:WaitForChild("Craft")
	
			local clickdetector=Instance.new("ClickDetector")
			local scriptfordestroy=rightclickscript:Clone()
			clickdetector.Parent=part
			
			scriptfordestroy.Parent=clickdetector
			part.Anchored=false
			part.CFrame=CFrame.new(x,y,z)
			part.Rotation = Vector3.new(0,0,0)
			part.Size=Vector3.new(2.2,2.2,2.2)
			part.BrickColor=BrickColor.new(brickcolor)
			if part.BrickColor==BrickColor.new("Pastel Blue") then
				part.Transparency=0.4
				part.Reflectance=0.4
			end
			print("aa")
			part.Material=material
			wait(0.1)
			part.Anchored=false

3 comments

0

Could you take a video of your problem?

0

sure

0

here is an image https://ibb.co/VV3Qy57

local part = workspace.Part
part.Anchored = true
part.Position = Vector3.new(0, 0, 0)
local part2 = part:clone()
part2.Parent = Workspace
part2.Anchored = false
part2.Position = Vector.new(1,0.5,0)

1 comment

0

hey thank you but the part2 does not goes inside of partone it goes next to it please help

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