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

How to load guns for team?

Asked by 8 years ago

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

1 answer

Log in to vote
2
Answered by
ImageLabel 1541 Moderation Voter
8 years ago

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)
0
What script should it be? Presiwakaflockaflame 0 — 8y
0
What is script for guns? Presiwakaflockaflame 0 — 8y
0
Make it a server script in ServerScriptService ImageLabel 1541 — 8y
0
NVM. It's working. Presiwakaflockaflame 0 — 8y
Ad

Answer this question