[FIXED] Block building system has duplicate blocks in the same position

Hey, I’m Peter, recently I’ve created an entire block building and breaking system from scratch with hundreds maybe even thousands of lines of code.

The issue with it tho is that sometimes when you click too fast or you are clicking in a certain area multiple blocks can be in the same position. I am trying to find a solution to avoid this problem.

I’ve tried a few things but they all didn’t work out, I’m not sure what I can do at this point.

I’ve gotten up to 15+ blocks in one singular 3 by 3 area at one point, I also won’t release the code because it’s so large that if I don’t release it all it won’t make sense. I just don’t want to let others take all my work.

Cheers! :smiley:

  • PitaPata

Well, you need to provide the code, otherwise we can’t help you much, you could maybe try to add a debounce if you haven’t done it alreadry.

Example:

local Debounce = true
local DebounceDelay = 0.5
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
local mouse = plr:GetMouse()

mouse.Button1Down:Connect(function()
      if Debounce == true then
          Debounce = false -- Disables Requests
          delay(DebounceDelay, function()
              Debounce = true -- Enables Requests Again
          end)
          -- Do code
      end
end)

If the code is too large as you say, you can try sending a simple repro; other than that, not much help can be provided.

What if you shoot a raycast to where the new block will be placed if it intersects with a block there then don’t place a new block if not then there you go place the block

1 Like

Thanks for your time everyone but I have been working on a patch and it works.