Currently working on my placement system, and each model has a PrimaryPart (a Hitbox)
Point of the Hitbox is for when placing furniture, so furniture can’t intersect. I have a separate system checking for collision of hitboxes for furniture, however, I am working on walls. Now walls also have a Hitbox, as that Hitbox is what’s used for the movement and players can intersect walls, however, you can currently spam click on the same spot and place the same wall on top of each other. The chances of this becoming a massive issue in my game is unlikely (as it costs money to place walls down, so no point in placing 100 walls in the same spot) but I still want to stop this from happening in case somebody accidentally double clicks.
So in short, is there a way to check for models PrimaryPart having the same position as an already placed item? I know I could probs do something like
if placingModel.PrimaryPart.Position == model.PrimaryPart.Position then print('Can't place') end
put if there are hundreds of models.
Tried using something like this:
click = mouse.Button1Down:connect(function()
for _, allModels in pairs(playersPlot.Purchases:GetChildren()) do
if wallClone.PrimaryPart.Position ~= allModels.PrimaryPart.Position then
click:Disconnect()
renderStepped:Disconnect()
place:FireServer(wallClone.Name, wallClone.PrimaryPart.CFrame)
wallClone:Destroy()
self:StartPlacing(playersPlot, mouse, wallType)
end
end
end)
But that ended up firing the place event 30-40 times