Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 2 years ago

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)
0
if plr.Team.Name == "Humans" then should do the trick RAFA1608 543 — 2y

1 answer

Log in to vote
1
Answered by
zane21225 243 Moderation Voter
2 years ago

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)
Ad

Answer this question