This script gives a player an item from ServerStorage called StrikeBall. However, I can not prevent a player from receiving multiple StrikeBalls. This is my attempt:
local Giver = script.Parent
local Gear = game.ServerStorage.StrikeBall
local debounce = false
function onTouch(part)
local Player = part.Parent:findFirstChild("Humanoid")
if Player ~= nil then
if debounce == false then
local Location = game:GetService('Players'):GetPlayerFromCharacter(Player.Parent)
if Location.TeamColor == Giver.BrickColor then
if Location.Character:FindFirstChild("StrikeBall") then
print("StrikeBall found in inventory.")
elseif Location.Backpack:FindFirstChild("StrikeBall") then
print("StrikeBall found in backpack.")
else debounce = true
local New = Gear:clone()
New.Parent = Location.Backpack
wait (5)
debounce = false
end
end
end
end
Giver.Touched:connect(onTouch)

2 comments
Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
I understand that, but I am at a loss for words when trying to explain this.