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

How to load guns for team?

I am wondering how I could load guns to a team? I.e, when player becomes red, he will receive guns.

1 answer

✓ Accepted answer

You could make a few folders in a service named after whatever teams you have and insert whatever tools you wish to award to players on the corresponding team.

local armory = "path so instance/service containing team folders"

local function setTools( player, team )
  local backpack = player.Backpack
  local starterGear = player.StarterGear
  
  starterGear:ClearAllChildren();
  backpack:ClearAllChildren();
  
  for _, child in next, armory:GetChildren() do
    if player[property] == BrickColor.new(child.Name) then
    
      for _, tool in next, child:GetChildren() do
      tool:Clone().Parent = starterGear
      tool:Clone().Parent = backpack
      end
    end
  end
end

game.Players.PlayerAdded:connect(function( player )
  player.Changed:connect(function( property )
    if property == "TeamColor" then
     setTools( player, player[property] )
    end
  end
end)

4 comments

0

What script should it be?

0

What is script for guns?

0

Make it a server script in ServerScriptService

0

NVM. It's working.

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