Heya everyone!
I’m working on a class-based shooter game and I’m trying to apply players their respective team character (BLOXXER’s players look like a stereotypical brickbattler while PWNER’s look identical albeit with a blue torso). The issue being that every time I tried applying the humanoid descriptions of the characters to the players, I always seem to get an error message. By the way, this code is a snippet of a ServerScriptService script.
-- // Teams
local RED = TEAMS.RED
local BLU = TEAMS.BLU
local NEUTRAL = TEAMS.NEUTRAL
local BLOX = ServerStorage:WaitForChild("TEAM_NPC_FOLDER").RED
local PWND = ServerStorage:WaitForChild("TEAM_NPC_FOLDER").BLU
local BLOX_HumanoidDescription = BLOX.Humanoid:GetAppliedDescription()
local PWND_HumanoidDescription = PWND.Humanoid:GetAppliedDescription()
local REDCount = 0
local BLUCount = 0
-- // Inserting Team
PLRS.PlayerAdded:Connect(function(Plr)
Plr.CharacterAdded:Connect(function(Char)
for _, Player in pairs(PLRS:GetPlayers()) do
local Player_Humanoid = Player:FindFirstChildWhichIsA("Humanoid")
if REDCount <= BLUCount then
Player.Team = RED
Player.TeamColor = RED.TeamColor
REDCount = REDCount + 1
-- Apply the BLOX's humanoid description to the player
local description = Instance.new("HumanoidDescription")
description:Clone(BLOX_HumanoidDescription)
Player_Humanoid:ApplyDescription(description)
else
Player.Team = BLU
Player.TeamColor = BLU.TeamColor
BLUCount = BLUCount + 1
-- Apply the PWND's humanoid description to the player
local description = Instance.new("HumanoidDescription")
description:Clone(PWND_HumanoidDescription)
Player_Humanoid:ApplyDescription(description)
end
-- Load the character with the new humanoid description
Player:LoadCharacter()
end
end)
end)