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

How to i give players on a team a certain tool?

Asked by
lushguy 13
5 years ago
Edited 5 years ago

I am making a game and I want it that every person that joins a certain team will receive a tool

local ItemToGive = game.ServerStorage.Tag --Tool I want to be given

local Handle = script.Parent:WaitForChild("Handle")
local TeamName = "Assassins" --Give the tool to everyone on this team
local NewTeam = game.Teams:FindFirstChild(TeamName)

Handle.Touched:Connect(function(partHit)
    if partHit.Parent:FindFirstChild("Humanoid") and partHit.Parent ~= script.Parent.Parent then
        local Tagged = partHit.Parent
        game.Players:GetPlayerFromCharacter(Tagged).TeamColor = NewTeam.TeamColor
    end
end)
0
Where is your script? User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

Make a table of tools for speficic teams. Then in your script, once someone switches a team or spawns, add the tool to their backpack.

Example:

local Tools = {
    ["Team Red"] = game.ServerStorage.Tool1,
    ["Team Blue"] = game.ServerStorage.Tool2
}

plr.CharacterAdded:Connect(function()
    if not plr.Team then
        return --return if they are not in any team
    end
    local tool = Tools[plr.Team.Name]
    if tool then
        tool:Clone().Parent = plr:WaitForChild("Backpack")
    end
end)
Ad

Answer this question