Make a script that makes sure their is no other copies of a tool

hello all who are reading this! i need help on something.

so i have 2 scripts that clone tools from ServerStorage, the 1st script gives tools from ServerStorage to a certain player in a table, and the 2nd script gives a tool to someone who owns the certain gamepass. both activate on me since the 1st script’s table has my playername in it and the 2nd script activates since when your the owner, you have access to your gamepass you made already. because they both activate, it gives me a duplicate of that tool it gives. so is there a way i can make it to where it wont give the gear if theres a duplicate of it located in the players’s backpack or character?

heres an example of the gears i have inside ServerStorage and which script gives what tool:

  • Tools

    • Staff
    • RedOrb
    • BlueOrb
  • Certain Player Script

    • Staff
    • RedOrb
    • BlueOrb
  • GamePass Script

    • Staff
    • RedOrb

Edit: I have now finished the script. both the Solution and my recent post have answered my question

4 Likes

the scripts are both Scripts, not LocalScripts. also i dont know how to get a players Backpack inside a Script.

2 Likes

i was wrong. i thought that you couldnt use the LocalPlayer thing inside of a normal Script. used your suggestion and it worked. thanks for the feedback!

after checking, the scripts dont work at all. the certain player tool giver scipt is my main tool giver script, and my gamepass script gives me a tool if i have a gamepass. if i disable the certain player script, the gamepass script doesnt work and gives this error: attempt to index field 'LocalPlayer'(a nil value). which brings me back to square one on doing this. i know its because you cant use LocalPlayer in a Scipt, like adding a varible that has game.Players.LocalPlayer in it. i would appreciate it if i could get help on this, as i would have to remove the code that checks if the player has a copy of the same tool, thus having to have the same tool duplicated in the backpack and making this post just straight up pointless. its also to note that i have varibles set in both scripts to do this:

local Players = game:GetService("Players")

I’ve finally have fixed my script. turns out i was using WaitForChild instead of FindFirstChild in the script. now its working perfectly fine.