Why does my script detect a part inside of it when there isn't a part inside of it?

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.

4 Likes

My viewmodel doesn’t have a hit box

3 Likes

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.

2 Likes

idk but try adding a loop so it always checks for anything overlapping??

3 Likes

it does have a loop, its going through a RunService.RenderStepped loop

2 Likes

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.

2 Likes

It’s okay to make mistakes. Just check for possible solutions next time.

1 Like

I found out it wasn’t that, it still doesnt work :confused:

1 Like

I already know why it’s happening, it’s a common problem with physics related properties.

2 Likes

why is it happening??? pls tell me

1 Like

Scroll up.

It’s because the surfaces are touching, not really because it’s going inside another part. Roblox thinks it’s still in-bounds.

1 Like

so how can I fix this and change it to when a part is inside of another part not touching surfaces?

2 Likes

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)
2 Likes

I tried moving the attachments where the viewmodel snaps a bit further away and it worked, but now theres a gap :confused:

1 Like

Are you able to make the gap very small, like 0.001 studs?

3 Likes

k, ill try this now and let u know if it works

3 Likes

i changed my move to 0.01 and it still did this

3 Likes

i did it very small, still a gap…

2 Likes

Even with 0.001 studs? It’s barely noticeable.

2 Likes

yep, still a gap… :frowning: lemme try even smaller

2 Likes