I want to keep checking if my tool, pistol, is in the character. Here's the script I tried to make:
game.Players.PlayerAdded:Connect(function(player) local character = player.Character or player.CharacterAdded:Wait() while true do wait(1) for i, v in pairs(character:GetChildren()) do if v.Name == "Pistol" then print("Pistol found") end end end end)
Tool has two useful events which may be helpful for you, these are Equipped
and Unequipped
Using your example you could detect what tool is equipped through this method:
game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) for _, Tool in pairs(Player.Backpack:GetChildren()) do if Tool:IsA('Tool') then Tool.Equipped:Connect(function() print(Tool.Name .. ' has been equipped by ' .. Player.Name) end) end end end) end)