Not able to find tool in player

Hey there! I’m Noah, and I’m trying to create an order system for a group. Right now, I’m trying to create a system where if you hold out an item and click “Add Item,” it will remove it from your inventory and put it into a folder called “storage” (player > storage) where it can be given to the player when you press “submit.” I’m having trouble with it because, on the server-side, it says that it’s not able to find the tool (shown below), while in my local script, it can find it.
image
Local script:


Sever script: image

I have tried character:FindFirstChildWhichIsA("Tool"), but that has shown the exact same output as the method I’m currently using now. I have double-checked that the tool is under the player’s character, which it is, and I am very confused as to why it isn’t working.

All help will be appreciated. :smiley:

1 Like

So when you fire the tool.Name to server, did you ever attempt to print out tool.Parent on the server side?

1 Like

Hi there! It shows that tool is nil, which means that printing out tool.parent would result in an error.

Mk… Might your tool be in the backpack rather than your storage?

its hard for me to determine what storage[1] and storage[2] is so if you can show a sample of that itd be amazing, in other words, what are you trying to index on the server side?

1 Like

Maybe your tool was instantiated from the client, therefore it hasn’t been replicated to the server?

1 Like

I apologize for being vague on what storage[1] and storage[2] do.

storage[1]: A true or false statement, as I have a lot of arguments for my remote event
storage[2]: The name of the tool

Hi there! I created the tool from the command bar, which is on the server side, so I don’t think this is the problem.

ok I see your problem, you are most likely replicating a name rather than an object to the server, so that all server has is a string, which means that it doesn’t know what that string is going to

1 Like

On the server side, I am trying to index the tool which is in the player’s character (meaning that they’re holding it).

I tried it w/ the object, but it didn’t work, so I tried doing it w/ the name.

maybe try this

local tool = game:GetService('Players'):FindFirstChild(plr.Name).Character:FindFirstChild(storage[2])

if that doesnt work, we’ll try to locate their character first and run a for loop to try return any tools thats there, do let me know before proceeding

1 Like

This would have the exact same result of what I’m doing now as the player is defined via the remote event, so nothing would change.

Already ran a for loop, it didn’t show the tool.

bizzare… so to clarify:

  • the player has their tool equipped
  • they click on a button and that tool goes from player’s character to the storage

please correct me if im wrong!

1 Like
  1. Yes, they have their tool equipped.
  2. Yes, they click this button and what’s supposed to happen is that their tool goes into storage (plr > storage).

I contacted you on Discord (nowah#6507) so that we could make more progress w/ this.

Ive never tried to parent an equipped tool directly to another place…

Try unequip their tool first so that the tool ends up in player’s backpack, and move the tool from the backpack to the Storage folder. To do that, you can do

game.Workspace[plr.Name]:FindFirstChild('Humanoid'):UnequipTools()

local tool = game.Players:FindFirstChild(plr.Name).Backpack:FindFirstChild(storage[2])

edit: im on a school computer which blocked discord and my current location isnt giving me the greatest signal for cellular data

1 Like

Okay! I’ll try this now. Thanks so much for all the help! :smiley::sunglasses:

1 Like

Hi there! While this didn’t work, I’ve narrowed down the problem to one thing:
Client-Server replication

My tool isn’t replicating between them, and I’m working to fix that right now. Thank you so much for your help! It’s truly appreciated. :sunglasses:

1 Like

Hey there! I just found what was wrong:
I didn’t realize that if you were on the client and were using the command bar, it would run the script locally, which was the big problem. Thank you so much for helping though.

3 Likes