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

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

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)

1 comment

0

Where is your script?

1 answer

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)

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