The goal is to clone to models containing Packages, into the player based on a players team. EDIT:I added a changed function, but I get the errer that changed is not a member?
local Player = game.Players.LocalPlayer repeat wait() until Player.Character ~= nil and Player.TeamColor ~= BrickColor.new("White") local AwareModel = game.ReplicatedStorage.Aware local SoldierModel = game.ReplicatedStorage.Soldier function GiveParts(Model) for _, Object in pairs(Model:GetChildren()) do Object:Clone().Parent = Player.Character end end function onChanged(TeamColor) if Player.TeamColor == BrickColor.new("Crimson") then GiveParts(AwareModel) elseif Player.TeamColor == BrickColor.new("Medium blue") then --Easier for me to have them seperate GiveParts(SoldierModel) elseif Player.TeamColor == BrickColor.new("Pearl") then --Easier for me to have them seperate GiveParts(SoldierModel) end end Player.TeamColor.Changed:connect(onChanged)
Thanks!
**The below answer is given under the assumption the script in question is a LocalScript and is in the player's PlayerGui, Backpack or Character. **
local Player = game.Players.LocalPlayer repeat wait() until Player.Character ~= nil and Player.TeamColor ~= BrickColor.new("White") local AwareModel = game.ReplicatedStorage.Aware local SoldierModel = game.ReplicatedStorage.Soldier function GiveParts(Model) for _, Object in pairs(Model:GetChildren()) do Object:Clone().Parent = Player.Character end end if Player.TeamColor == BrickColor.new("Crimson") then GiveParts(AwareModel) elseif Player.TeamColor == BrickColor.new("Electric Blue") or Player.TeamColor == BrickColor.new("Pearl") then GiveParts(SoldierModel) end
Line 7: Created a function to give the model's contents to the player; easier than typing out the same thing for the three different TeamColors.
Line 8: Iterating through the given model, so that we're able to give the player the correct "kit"
Line 15: Both TeamColors receive the same, so we might as well just use 'or' rather than using a completely different if statement for the same thing.