I have a script that kicks a user if they have a certain item in their inventory. But how can I detect when an item is added?
When an item is added i want it to call my itemAdded()
function
I currently have this code
function itemAdded(item) if item.Name == "HopperBin" then item.Parent.Parent:Kick("You are not allowed that item") end end
You can use DescendantAdded()
and connect it to the function.
function itemAdded(item) if item.Name == "HopperBin" then --Changed how we get the Player then we kick game.Players:GetPlayerFromCharacter(item.Parent):Kick() end end --This would check if something was added to Player1's Character Model in Workspace game.Workspace.Player1.DescendantAdded:connect(itemAdded)
You'll likely need to change the path game.Workspace.Player1 to where the "inventory" is at.