Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My tool giver gives a tool to all teams how do I make it only give to one team?

Hello, I have a script that will give a pistol. However, I do not want infected players to be able to access the tool, I only want Humans to be able to. There are 2 teams. "Humans" and "Infected" How can I make the script to only give the tool to "Humans"?

Here is the script

local tool = game.ServerStorage.Pistol -- Pistol is the item
local clone = tool:clone()
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	if clone.Parent ~= plr.Backpack then
		clone.Parent = plr.Backpack
	else            
	end
end)

1 comment

0

if plr.Team.Name == "Humans" then should do the trick

1 answer

✓ Accepted answer

You can check the name of a player's team by doing plr.Team.Name So I just added that to your code

local tool = game.ServerStorage.Pistol
local clone = tool:clone()
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	if plr.Team.Name == 'Humans' then
		if clone.Parent ~= plr.Backpack or plr.Character then
			clone.Parent = plr.Backpack           
		end
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.