How would I make it so that depending on a players team, they will be a custom character?
You would do a check using the teams service for their team (or through the use of StringValues alternatively) and then replace the players current character with the path of the custom model you want. This can be done by doing something like this:
local teams = game:GetService("Teams")
if player.Team == teams["Name of your team"] then
local customCharacter = the character model you want
customCharacter.Name = player.Name
player.Character = customCharacter
customCharacter.Parent = workspace
This isn’t working at all
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local LobbyCharacter = game.Workspace:WaitForChild("TeamCharacters"):WaitForChild("WhiteTeamCharacter")
Players.PlayerAdded:Connect(function(player)
player.Team = Teams.Lobby
if player.Team == Teams.Lobby then
LobbyCharacter.Name = player.Name
player.Character = LobbyCharacter
LobbyCharacter.Parent = workspace
end
end)
EDIT:
Apologies im tired, misread the meaning of the team definiton there, used to it being set up automatically through spawns.
Try changing
if player.Team == Teams.Lobby then
to
if player.Team == Teams[“Lobby”] then
2nd Edit:
On attempt myself I noticed this method of setting the players character with PlayerAdded doesn’t seem to work well (In my case on my own game I call a function when the game has well loaded in, and the player then resets and spawns with his new character model)
What kind of custom character is it? Is it just a new outfit, or are there custom accessories, or is it a new character rig entirely?
If it’s just a different outfit or uses custom accessories, it might be worth looking into HumanoidDescriptions and Humanoid:AddAccessory()
It seems part of the problem here is that you’re not making a clone of LobbyCharacter
, and you’re setting Player.Character
to LobbyCharacter
before it’s loaded into the workspace.
Additionally, make sure that LobbyCharacter
has a humanoid inside it.
Its just a R6 Rig thats white with a decal on its Torso.
Earthier way though, I don’t want to list every single HumanoidDescription thing or anything
local teams = game:GetService("Teams")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local character = char
if player.Team == teams["Lobby"] then
local character = game.ReplicatedStorage.Default:Clone()
character.Name = player.Name
player.Character = character
character.Parent = workspace
end
end)
end)
This works on testing, however does something strange with replicating the players model many times for me, since its not something ive tried before hopefully a more experienced scripter can come in and clarify what needs to be changed from here.
maybe its because
local character = char
has the same variable as local character = game.ReplicatedStorage.Default:Clone()