Starter Characters does not load in after player resets

I have a script inside ServerScriptStorage that makes 8 players from 8 different teams have unique starter characters. But there is one problem. Every time my player resets, he goes back into his original player model from roblox. If anyone is willing to help change or add something inside the code and fix the problem, that would make my day. Here’s the code / script. Scroll down for a video too.

local RedDummy = game.Workspace:WaitForChild("Redd")
local BlueDummy = game.Workspace:WaitForChild("Bluee")
local OrangeDummy = game.Workspace:WaitForChild("Orangee")
local PurpleDummy = game.Workspace:WaitForChild("Purplee")
local BrownDummy = game.Workspace:WaitForChild("Brownn")
local PinkDummy = game.Workspace:WaitForChild("Pinkk")
local GreenDummy = game.Workspace:WaitForChild("Greenn")
local YellowDummy = game.Workspace:WaitForChild("Yelloww")

local function Changeplayer(player)
	local NewChar

	if player.Team.Name == "Red" then
		NewChar = RedDummy:Clone()
	elseif player.Team.Name == "Blue" then
		NewChar = BlueDummy:Clone()
	elseif player.Team.Name == "Orange" then
		NewChar = OrangeDummy:Clone()
	elseif player.Team.Name == "Purple" then
		NewChar = PurpleDummy:Clone()
	elseif player.Team.Name == "Brown" then
		NewChar = BrownDummy:Clone()
	elseif player.Team.Name == "Pink" then
		NewChar = PinkDummy:Clone()
	elseif player.Team.Name == "Green" then
		NewChar = GreenDummy:Clone()
	elseif player.Team.Name == "Yellow" then
		NewChar = YellowDummy:Clone()
	end

	local CHAR = player.Character or player.CharacterAdded:Wait()
	local AnimateS = CHAR:WaitForChild("Animate"):Clone()
	local HealthS = CHAR:WaitForChild("Health"):Clone()

	AnimateS.Parent = NewChar
	HealthS.Parent = NewChar

	player.Character = NewChar
	NewChar.PrimaryPart.CFrame = CHAR.PrimaryPart.CFrame
	NewChar.Parent = game.Workspace
	CHAR:Destroy()
end


game.Players.PlayerAdded:Connect(function(player)
	warn(player, "joined", player.Team.Name, "team")
	Changeplayer(player)

	player:GetPropertyChangedSignal("Team"):Connect(function()
		warn(player, "joined", player.Team.Name, "team")
		Changeplayer(player)
	end)
end)

1 Like

you need an event handling Players.CharacterAdded inside the PlayerAdded function with then you need to locate the Chars humanoid and do an if loop to see if it dies, once it does you can do that changePlayer() or another respawn function at your will

You’re gonna wanna edit your PlayerAdded event to include a CharacterAdded event. As of right now, it only loads the starter character upon first joining because that’s the only time PlayerAdded is ran for each individual player. CharacterAdded is what you want, as that runs everytime the character is added (resets, loads, etc.).

game.Players.PlayerAdded:Connect(function(player)
	warn(player, "joined", player.Team.Name, "team")

	player:GetPropertyChangedSignal("Team"):Connect(function()
		warn(player, "joined", player.Team.Name, "team")
		Changeplayer(player)
	end)

	player.CharacterAdded:Connect(function(character)
		Changeplayer(player)
	end)
end)

This should work! Let me know if you have any problems.

Hey sorry for the wait and thanks for reaching out. Anyway, i updated my script and i have a slight bigger problem now. My player duplicates everytime i reset, and my character(startercharacter) is duplicated 3 or 4 times. Heres a video and my code too. (Basically the same code you posted.)

game.Players.PlayerAdded:Connect(function(player)
	warn(player, "joined", player.Team.Name, "team")
	
	player:GetPropertyChangedSignal("Team"):Connect(function()
		warn(player, "joined", player.Team.Name, "team")
		ChangeAV(player)
	end)

	player.CharacterAdded:Connect(function(character)
		ChangeAV(player)
	end)
end)

yeah i was aware of this i just had no idea on how to put it together

Let’ switch gears a bit. Try something that doesn’t revolve switching the player’s character, as that is quite the hassle in the first place further down the road.

Let’s use HumanoidDescriptions.

First start off by getting every humanoid Description.

Second, scratch that stack of if statements checking every team! :laughing: Make a folder, store all the characters in there, and run a for loop to create a dictionary with every team dummy:

local dummyFolder = game.Workspace:FindFirstChild("DummyFolder")
local dummyDescriptions = {}

for _, dummy in dummyFolder:GetChildren() do
     dummyDescriptions[dummy.Name] = dummy.Humanoid:GetAppliedDescription()
end

For your ChangePlayer function

local function ChangePlayer(player) -- Follow CamelCasing rules!
	local NewChar

    local description = dummyDescription[player.Team.Name]

	local CHAR = player.Character or player.CharacterAdded:Wait()
	local AnimateS = CHAR:WaitForChild("Animate"):Clone()
	local HealthS = CHAR:WaitForChild("Health"):Clone()

	AnimateS.Parent = CHAR
	HealthS.Parent = CHAR

	player.Character.Humanoid:ApplyDescription(description)
end

And like that, boom! we just cut down a bunch of lines.

2 Likes

Yeah it looks like you got it on the right track, and yes i know the code is messy lol. I was going to do more tinkering later but i was trying to fix the problem first. Also, I’ve never used Humanoid description before and its all making me scratch my head.

edit: nvm im complicating my self right now

My “Source”

Think of HumanoidDescription as a blueprint. The cool part about HumanoidDescriptions is that you are not forced to hop around characters like crazy to ensure proper looks. Humanoid Description allows you to take the character designated to the player and shape it however you please.

Your blueprints, in this example, are the dummies in the dummy folder. You have to customize them how you see fit. Once that is done, all there is to do now is tell ROBLOX “hey, I need this player’s character to look exactly like this dummy.” Then ROBLOX will take that blueprint and construct the character using that model’s looks.

In addition to that, it takes all the hats off which helps in your case to ensure that nothing is where it’s not supposed to be. This finally sets the skintone to the correct color, which is only 6 of many components of a HumanoidDescription object. A HumanoidDescription object also contains things like:

  • Which hats the player will wear
  • What animations will be played when walking or idling
  • Accessories all around the player

Let me know if that makes sense.

2 Likes

makes perfect sense, i appreciate the clarification lol. So what you’re saying is to (in my case) use the humanoid description to add the skin tone for the model?

Exactly.

VERY IMPORTANT AS WELL!

Make sure when editing the character, you are also applying it to the humanoid description as well which is located within the Humanoid of your character. This will ensure proper porting. There is no current way of transfering what is currently on the character to the Humanoid Description, which means you have to do it manually!

Good luck! Let me know if you run into any issues.

1 Like