Script gives tool if tool is equipped despite checking inventory

The code checks for if the tool is already in someones inventory, but for some reason it doesnt apply if that said tool is equipped, how do i prevent that from happening??

Toolname = "EBR14"

function boop(Player)
 if not Player.Backpack:FindFirstChild(Toolname) then
  local Tool = game.ReplicatedStorage.usedTools[Toolname]:clone() 
  Tool.Parent = Player.Backpack
 end
end
script.Parent.ProximityPrompt.Triggered:connect(boop)

when a player equips a tool the tool is parented to their character, so it wont be in the backpack. when you check if its in their backpack also check if its in their character

1 Like

how would you write the script?

Toolname = "EBR14"

function boop(Player)
 if not Player.Backpack:FindFirstChild(Toolname) and not Player.Character:FindFirstChild(Toolname) then
  local Tool = game.ReplicatedStorage.usedTools[Toolname]:clone() 
  Tool.Parent = Player.Backpack
 end
end
script.Parent.ProximityPrompt.Triggered:connect(boop)
1 Like

But please know that if you dont understand a basic concept like this please please go learn the basics, it will help you so much in the long run

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.