How should I go about this collecting method?

Lets say there’s a bunch of loot on the ground and I want to collect it when the player is x distance close to it. there’s two diff ways I’m thinking of doing this and one is have a part welded to the player and use :GetPartsInPart(part) and the other is just scanning through the folder of all the items that contains all the loot and checking the distance to see if its close enough. but both of these would have to be constantly ran with a while loop or a RunService like RenderStepped. The third option that I’d assume isn’t correct is welding a part and just using the touch event. Do u know which method I should use and why it’s better than the others?

This could be really inefficient if you have a ton of objects, but here’s what I would do

Each loot would be categorized in a model, hitbox and the actual item. the hitbox size could be like 10,1,10

use a touched event for that

You could try using an invisible “Hitbox” part, and connect a .Touched event inside of it.

1 Like

Is using a touched event really the way it should be done? Feels wrong somehow

I did pretty much the same thing in my game, you should use a raycast in front of the player and check if it hits anything that should be collected. Make sure you set the max distance to something realistic (the distance the player holds his hand out) and make sure that the raycast only hits model parts (not any GUI or the terrain).