#Optimizing custom item pickup system

1 messages · Page 1 of 1 (latest)

spark sinew
#

I made a custom item pickup system that basically checks if the item can be hit with two raycasts (originating from humanoidrootpart and camera) and 8 studs or less away from the player. Any item that fits the criteria gets parented to a folder called DetectedItems on Workspace. After that, a localscript will check which of those items are the closest to the players cursor and highlights them to signal the player that it can be picked up. The issue here is that the game lags when there are multiple items near each other and the highlight has to jump from one item to another causing the game to lag. Are there any ways to optimize this system to prevent lag?

brittle wadi
#

The highlight is probably the easiest to fix

#

From what I remember it's possible to have it in something like replicated storage and then just set it's adornee property to the model of choice

#

That being said are you checking the distances every frame?

spark sinew
# brittle wadi That being said are you checking the distances every frame?

it was like that in the old version, i changed it to every 0.2 seconds now tho. I tried going above 0.2, but it feels awful. It's like having a cooldown from picking up items. I think I could make it work by adding an animation while picking up items but im hoping to just grab it immediately without delays.