So this script gives a tool when the player touches a part:
local allow_duplicates = false
local allow_team ={
"Rank_1"
}
local GamepassID = 4564666
local button = script.Parent
local debounce = false
local toolfolder = button.Parent["folder"]
local toolstorage = {}
for i, tool in pairs(toolfolder:GetChildren()) do
table.insert(toolstorage, tool:clone())
end
toolfolder:Destroy()
local block = button.Parent:FindFirstChild("Block")
if block ~= nil then
if block:FindFirstChild("NameDisplay") then
if #toolstorage > 0 then
block.NameDisplay.TextLabel.Text = toolstorage[1].Name
else
end
end
end
button.Touched:connect(function(hit)
if debounce then return end
if hit == nil then return end
if hit.Parent == nil then return end
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil then
if player:FindFirstChild("Backpack") then
local allow = true
if #allow_team > 0 then
local teams = game:GetService("Teams"):GetChildren()
if #teams > 0 then
allow = false
for i, team in pairs(teams) do
for i, allowedteamname in pairs(allow_team) do
if team.Name == allowedteamname then
if player.TeamColor == team.TeamColor then
allow = true
end
end
end
end
end
end
if not allow_duplicates then
for i, tool in pairs(toolstorage) do
if player.Backpack:FindFirstChild(tool.Name) then
allow = false
end
end
end
if allow then
debounce = true
button.BrickColor = BrickColor.new("Black")
for i, tool in pairs(toolstorage) do
local newtool = tool:clone()
newtool.Parent = player.Backpack
end
wait(2)
debounce = false
end
end
end
end)
It's in a script inside the part. I'm trying to make it so that it only works if the player has a specific gamepass, but the thing is, I've never done anything with gamepasses before. I don't know how I would incorporate it into the script, please help.
