How do I set this giver so that if someone already has this tool in their starter pack it will not give them another?
local Part = script.Parent --Part to get touched local Tool = game.ReplicatedStorage["OCA Nano"] --The tool you want to give them local TeamColor = "Bright blue" --Team color here Part.Touched:connect(function(hit) local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player and Player.TeamColor == BrickColor.new(TeamColor) then Tool:Clone().Parent = Player.Backpack Tool:Clone().Parent = Player.StarterGear end end)
In your if
statement you can look to see if the tool is in the backpack
or the StarterGear
by doing this:
if not Player.Backpack:FindFirstChild("OCA Nano") and not Player.StarterGear:FindFirstChild("OCA Nano") then
I used and not
which means if that statement is false(In this case it would mean if it's not in the backpack or startergear). I also used FindFirstChild
which looks for a child in Startergear
and the backpack
.
So that's how you do a quick check. Just check if the tool is in BackPack or startergear
Your final code should look like this.
local Part = script.Parent --Part to get touched local Tool = game.ReplicatedStorage["OCA Nano"] --The tool you want to give them local TeamColor = "Bright blue" --Team color here Part.Touched:connect(function(hit) local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player and Player.TeamColor == BrickColor.new(TeamColor) and not Player.Backpack:FindFirstChild("OCA Nano") and not Player.StarterGear:FindFirstChild("OCA Nano") then Tool:Clone().Parent = Player.Backpack Tool:Clone().Parent = Player.StarterGear end end)