Trying to find a tool in a player's backpack always returns nil

Hi.

It’s been a few hours and I just can’t wrap my head around this one.
I’m working on a move that lets the player grab-lock another player.
This requires multiple things to be done. One of these things is disabling the enemy’s tool.
However, every time I have it look for the tool in the enemy’s backpack, it tells me it’s simply not there,
while in reality the enemy has been using their tool for quite some time.
I’ve tried rechecking every time it couldn’t find the tool, but alas.
I’m pretty much out of options here.

This error happens on line 236

Brief instance where "hit" (the red orb, AKA the hitbox) accepts Touched before it is destroyed

Image from Gyazo

Code that fires the event, located in a LocalScript in the tool

image

Code that responds to the player's client that initiated the attack, located in ServerScriptService

NOTE: This all works perfectly fine everywhere but online mode. This does work in server simulation(F7).

Any help is very appreciated, thanks in advance!
If any additional information is required, I will gladly supply that.

1 Like

You might want to be checking in the enemy character as well because equipped tools are parented to the character and not the Backpack.

local enTool  = enemy.Backpack:FindFirstChildOfClass("Tool") 
or enemyChar:FindFirstChildOfClass("Tool")
4 Likes

That’s the odd thing. It’s never there in the actual character, even though the tool is in StarterPack

I mean, look!

EDIT: So apparently, when equipping the tool, the tool gets moved from the backpack into the character model, and the reversed happens when you unequip it.
Why? I have no idea, but it looks like checking for both is necessary.
I will update this post once my issue has been fixed or not (because i have no one to test with atm)

The reason for that is because when you equip a tool (such as a key), the key would be parented to the character, so it can be used properly. If that makes any sense.
If you think of it in a real life way (with a backpack and a flashlight), you need to take the flashlight out of the backpack to use it.
Thought I’d mention like the reason. :joy:

2 Likes