Hello, so I've figured out how to remove tools in backpack, but when you equip a tool it wont get deleted since it's no longer in the backpack, could somebody tell me what I'm missing?
1 | local pack = player.Backpack |
2 | local findSword = pack:FindFirstChild( "ClassicSword" ) |
3 | local Char = workspace:FindFirstChild( "Player" ) |
4 | local equippedSword = Char:FindFirstChild( "ClassicSword" ) |
5 | if findSword then |
6 | findSword:Destroy() |
7 | elseif equippedSword then |
8 | print ( "sword is equipped!" ) |
Instead of using Workspace:FindFirstChild(“Player) (which wouldn’t work anyway because it would be looking for a child of workspace named “Player”)
Use player.Character or player.CharacterAdded:Wait() to look for the character.
1 | local pack = player.Backpack |
2 | local findSword = pack:FindFirstChild( "ClassicSword" ) |
3 | local Char = player.Character or player.CharacterAdded:Wait() |
4 | local equippedSword = Char:FindFirstChild( "ClassicSword" ) |
5 | if findSword then |
6 | findSword:Destroy() |
7 | elseif equippedSword then |
8 | print ( "sword is equipped!" ) |
try with function, then add script.Parent.Equipped:Connect(YourFunctionName)