Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i Detect cloned tools in backpack with a script?

Asked by 3 years ago
local ToolName = "FireBall"

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        if Player.Backpack:FindFirstChild(ToolName) then
            print("Player has tool in backpack!")
        else
            print("Player does not have tool in backpack!")
        end
    end)

end)

this just detect if i have the tool or not but not if it has a duped it happens for me somehow

1 answer

Log in to vote
0
Answered by 3 years ago

you would add a not statement to check if the player already has the item or not you can do this like this

local ToolName = "FireBall"

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        if Player.Backpack:FindFirstChild(ToolName) and not player.StarterGear:FindFIrstChild(ToolName) then
            print("Player has tool in backpack!")
        else
            print("Player does not have tool in backpack!")
        end
    end)

end)

here the 'and not player.StarterGear:FindFirstChild(toolname)' will check if the tool is already in backpack or not

Ad

Answer this question