How do I change the player's StarterCharacter from a server script when the game is running?

I tried to ask this to ChatGPT, but the code didn’t quite work.

local players = game:GetService("Players")
local characterModel = game.Workspace.NewCharacter

players.PlayerAdded:Connect(function(player)
    local function characterAdded(character)
        character.Humanoid.Died:Connect(function()
            local characterAppearance = Instance.new("Appearance")
            characterAppearance.Parent = player.Character
            characterAppearance.Child = characterModel:Clone()
        end)
        player.CharacterAdded:Disconnect(characterAdded)
    end
    player.CharacterAdded:Connect(characterAdded)
end)

4 Likes

“the player’s” as in a specific player, or all players?

if you want all players, simply have the script place a model named “startercharacter” into the starter character file.

if you want a specific player, I dont know if this is the best way, but I would say it would be to use the character added function, grab the character, and change the humanoid description as documented here:
https://create.roblox.com/docs/reference/engine/classes/HumanoidDescription

and if you for some reason means to have the player spawn a a specific character, simply name the character model “startcharacter” and place it in the startercharacter folder

That works, but that isn’t documented in the website unless you’re saying to go through each property of the instance itself and give a new value.

silly me forgot thee wasn’t a function for that specific thing

You could always create a alt account with the specific character look then use getfromuserId

Sure, but what if I want to use a pre-made model created in studio and not using an actual player character’s model?

there we go

Well that didn’t work, don’t where’s the problem:

local Players = game:GetService("Players")

Players.CharacterAutoLoads = false

Players.PlayerAdded:Connect(function(player)
	print(Players.CharacterAutoLoads)
	print("L")
	player.Character = game.ServerStorage.StarterCharacter
	print(player.Character)
	player.Character:WaitForChild("Humanoid").Died:Connect(function()
		print("DIED")
		player:LoadCharacter()
	end)
	player:LoadCharacter()
end)

I had made sure the game settings of my game makes sure so that anyone can use any types of rig in the game. My StarterCharacter in ServerStorage container is a R6 rig.

Never mind, fixed it!

local Players = game:GetService("Players")
local Clone = game.ServerStorage.Noob:Clone()

Players.CharacterAutoLoads = false

Players.PlayerAdded:Connect(function(player)
	player:LoadCharacter()
	player.Character = Clone
	player.Character.Parent = workspace
end)
5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.