How to team lock gun giver ClickDetector script

I’ve been trying to establish a script that does not give the player a tool if they aren’t on selected team.

local ToolNames = {"Carl Gustaf"}
local Storage = game:GetService("ServerStorage")
local Teams = game:GetService("Teams")

local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")

ClickDetector.MouseClick:Connect(function(Player)
	if Player and Player.Character then
		local playerTeam = Teams:(Player)
		if playerTeam and playerTeam.Name == "11th MEU" then
			local Backpack = Player:WaitForChild("Backpack")
			for i = 1, #ToolNames do
				local Tool = Storage:FindFirstChild(ToolNames[i])
				if Tool then
					Tool:Clone().Parent = Backpack
				end
			end
		end
	end
end)

Just changed a line. I beleive it should work now.

ill just believe you then

////////////////////////////////
///////////////////////////////

I’ve simply made it so the individual requesting help can have multiple teams requesting the weapon instead of a single team if needed.

I’ve been around before the time of this forum and had to use free models to learn. I know I can write my own code without the help of AI.