local Game = game
local Players = Game:GetService("Players")
local Teams = Game:GetService("Teams")
local ServerStorage = Game:GetService("ServerStorage")
local RedTeam = Teams.Red --Red team.
local BlueTeam = Teams.Blue --Blue team.
local RedCharacter = ServerStorage.RedCharacter --Character model for red team.
local BlueCharacter = ServerStorage.BlueChar --Character model for blue team.
local function OnPlayerAdded(Player)
local function OnCharacterAdded(Character)
if Player.Team == RedTeam then
Player.Character = RedCharacter --Override character with team's custom character.
elseif Player.Team == BlueTeam then
Player.Character = BlueCharacter --Override character with team's custom character.
end
end
Player.CharacterAdded:Connect(OnCharacterAdded)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
The problem with my code is with what happens when the player loads in, they’re met with not being able to move or interact with their environment
Have you checked if some parts inside the character are anchored? Maybe root part? Also I cleaned up your code, this should be way more efficient
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local ServerStorage = game:GetService("ServerStorage")
local function OnPlayerAdded(Player : Player)
Player.CharacterAdded:Connect(function()
if Player.Team == Teams.Red or Player.Team == Teams.Blue then
local NewCharacter = (Player.Team == Teams.Red and ServerStorage.RedCharacter or ServerStorage.BlueCharacter):Clone()
NewCharacter.Name = Player.Name
Player.Character = NewCharacter
NewCharacter.Parent = workspace
-- Wait after spawning the character
Player.CharacterAdded:Wait()
end
end)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
I told you that there could be compatibility issues with some scripts due to ACS 1.7.5, which, is why I got the error Saude is not a valid member of Model "Workspace.JellyM015".