How could I make ProximityPrompts visible through certain parts?

  1. Alright, so… Basically, I made a tool-dropping system that uses ProximityPrompts for you to pick those tools up and get them added to your inventory. Everything works just fine, but I ran into a slight issue.

  2. The issue that I ran into is if you drop more than one tool at the same spot, ProximityPrompts wouldn’t show up at all. Why does it do that? Because when a tool is dropped, that one invisible part that is used as a Collision Box, has its CanCollide property turned ON, which means CanQuery has also turned automatically ON. The tools themselves don’t have collisions with each other, because every single part within the tool has the same CollisionGroup, and therefore, ProximityPrompts don’t work if 2 or more tools are inside of each other.

  3. The easiest solution to that problem is to turn off RequiresLineOfSight property for those ProximityPrompts, but that would cause some unwanted issues like picking up a tool that is behind a wall/door. Another solution is to swap out ProximityPrompts with ClickDetectors, as they would work as long as those Collision Boxes aren’t somewhere out of sight. Another solution is to turn ON collision between tools, but that would cause other unwanted issues like tools glitching through the floor and not being able to be picked up again.

I searched up some posts about that, but all of them were about making ProximityPrompts behind certain parts invisible, what I’m trying to achieve is the opposite of that. So, is there any other way to make those ProximityPrompts work, while avoiding using any of the solutions that I’ve listed above?

This is how it’s supposed to work:

This is what it looks like when it doesn’t work:

Sorry if I missed something or picked the wrong category! This is my first post on DevForum.

4 Likes

Have you tried making a part the size of the gun (like a hitbox) and then add the proximity prompt in it?

That’s exactly how the whole system works. I also mentioned “that one invisible part that is used as a Collision Box” in the post itself, which is the thing that you’re talking about.
image
image

The issue is that if those 2 parts are located in each other, it wouldn’t let that ProximityPrompt appear due to CanCollide and CanQuery properties being enabled.
For example:

It works fine if the attachments are not inside of other Collideable Collision Boxes (hitboxes):

1 Like

The easiest solution would be to just make them collide with each other, but if you really dont want that you could move the attachment to the side so it sticks out from the part. You just move the attachment half of the hitboxes width (or a bit more if you notice prompt not showing or glitching). Issue with this is that attachment will only be on one side meaning that if hitbox is flipped on the other side attachment will be in the ground, you could simply add 2 attachments on both sides, but you could also just move the attachment to the side facing up like this:

local hitbox = script.Parent
local att = hitbox:WaitForChild("Attachment")

att.Position = Vector3.new(0,(hitbox.CFrame.UpVector.Y > 0 and 1 or -1)*hitbox.Size.Y/2,0)

You would just have to run this code when the gun is dropped and if it ever gets flipped. Keep in mind that you need to make attachment move on the axis that would be up and down for your hitbox which might not be y axis like in above code, so you might need to switch on which axis you are moving it.

1 Like

Could you not run a raycast each frame to check for stuff like walls colliding with your character and then turning off RequiresLineOfSight if it hits something? You can put your weapons and characters in an ignore list.

1 Like

That could work, but in my opinion, that’s just overcomplicating a lot of stuff. Currently, I’m trying a suggestion by @realmile with 2 attachments on both sides just a little outside of the Collision Box (DroppedHitbox), because to me it seems like the simplest way and the fastest way of fixing that. If some tool is inside of another, at least one of the attachments is guaranteed to be still visible as it’s gonna be outside of that part, in most cases, both are gonna be accessible.

I just figured it’d be cleaner since there could be other weapons or parts possibly intersecting that attachment? therefore rendering it useless. But that might not be an issue with your game? Not sure if you have droppable objects/ragdolls, or perhaps another player could cover that weapon?

1 Like

Yeah, that would definitely be cleaner and would let players pick up items underneath ragdolls, but I honestly don’t mind the fact that you can’t pick up dropped tools in some cases. Anyway, @realmile’s solution with 2 attachments works decent enough, although I think that there’s a very slight possibility that might not occur under normal circumstances, but it still is a thing and it will prevent players from accessing those prompts:


I think it’s gonna happen more often if there’s something with a bigger hitbox, but I can just add more ProximityPrompts… Anyway, I will have to replace those ProximityPrompts with something more consistent at some point, maybe something like raycasting to see if the player is looking at the item on the ground, check if it’s in range of the ray and if the player is holding a button to pick up that item. Something like that would work better.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.