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

How to Prevent Overlapping Whith Anchored On? [closed]

Asked by 4 years ago

This question already has an answer here:

how to prevent overlapping parts in roblox with 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.

0
Please read the dev hub JesseSong 3916 — 4y
0
thanks you_success -50 — 4y
0
Remove the instance if you dont want a new part JesseSong 3916 — 4y
View all comments (2 more)
0
The whole line JesseSong 3916 — 4y
0
then an error occurs attempt to index nil with 'Parent' you_success -50 — 4y

Marked as Duplicate by youtubemasterWOW and JesseSong

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

3 answers

Log in to vote
0
Answered by
rokedev 71
4 years ago

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.

0
I have postet the code below rekedev you_success -50 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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
0
Could you take a video of your problem? rokedev 71 — 4y
0
sure you_success -50 — 4y
0
here is an image https://ibb.co/VV3Qy57 you_success -50 — 4y
Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago
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)
0
hey thank you but the part2 does not goes inside of partone it goes next to it please help you_success -50 — 4y