What do you want to achieve? Keep it simple and clear!
I want to make it so that if a part is a little inside of another part then it will print(“Can’t place here”) and if there isn’t a part inside of it then it will print(“Placeable”). My script was working perfectly and now it stopped working. Here’s my code :
What is the issue? Include screenshots / videos if possible!
It just stopped working, Idk why. It was working perfectly fine.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried YT and DevForum.
See how the viewmodel part isn’t inside of the placed viewmodel, it still goes red even though its just touching it. Idk if this has anything to do with it but, my building system is like rust, so the viewmodel is snapping to the side of the placed viewmodel. And I made sure that the attachments won’t make them go inside of each other but just perfectly on the side of it. PLS HELP. I wanna get this done ASAP
It might be that the model that’s already there or the hitbox of the placed item are just a hair larger than the size you are checking for.
Try making your hitbox slightly smaller than the grid you are checking on. Say you have a 2x5x10 model, make the hitbox 1.99, 4.99, 9.99 instead so it doesn’t register something thats .02 studs overlap.
Even if Parts are .0001 (yes, Roblox does recognize less than .001 studs) overlapped you are going to have issues.
I just used the term hitbox to describe your viewmodel.
Did you try my suggestion? You may want to try 1 Transparent CanCollide false Part as your ‘hitbox’ so that any tiny little Parts sticking out from the model don’t cross into the other model.
Roblox treats parts that are simply touching surfaces, as in bounds. Even if they are not colliding together, they are touching.
If the part is in mid-air, touching absolutely nothing, then that would be classified as not in bounds.
How to fix it? I’m not entirely sure, but I would definitely not recommend making parts levitate a micro metre up, left or right, just to make them not touch.
I know what’s wrong, I just don’t know how to fix it.
You can try a magnitude check, but it can only be circular, not squared.
Here’s how a magnitude check works:
local part = workspace.Part
local distance = 10
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
while task.wait(0.1) do
if (character.HumanoidRootPart.Position-part.Position).Magnitude <= distance then
print("in radius")
end
end
end)
end)