Hello, so I have a button players can press to give them a football. But the issue is that they can spam and have like a million of them. The button works fine, just is there any way I can limit a players inv to having 1 football. A way where if a player has a football, the button recognizes it and does not let them have another.
You can check if the player already has a football inside their backpack or character.
If the player is having a tool in their hand it appears in game.Players.LocalPlayer.Character. Otherwise if unequipped it’s inside game.Players.LocalPlayer.Backpack.
function localPlayerHasTool(name: string): bool
if player.Character then
if player.Character:FindFirstChild(name) then return true end
end
return player.Backpack:FindFirstChild(name) ~= nil
end
...
if not localPlayerHasTool("Football") then
give:FireServer()
end
if not localPlayerHasTool(“Football”) then
give:FireServer()
end
In the code you posted above, you are checking if the player has the football. This means that the give event will only occur when the player doesn’t have the football. So, if they don’t have the football they can press the button and get it. If they do have the football, they cannot press the button.