Making a "permanent" starter character

What i’m trying to do is create a gui, that fires a remote event that changes the player’s character (like a morph) I want to make it so the player’s character is permanent (until they change the character from another button) How would i do this?

Any help would do.

Hey,
You can save the selected morph name In a variable/value. And when the player respawns, just change them to the selected morph.
And when they select another morph, change that variable/value.

1 Like

Thanks for answering!

Just trying that out, i’ll mark your answer as a solution if it works.

Here’s what i’ve got so far:

Not sure what do do next.

Hey, can you send it as code? I’ll make changes and try to explain.
Do you want it to also load when the player re-joins the game?

2 Likes
local function ChangeCharacter(player)
	player.CharacterAdded:Connect(function()
	local charactervalue = player.CharacterValue.Value
	local search = game.ReplicatedStorage:FindFirstChild(charactervalue):Clone()
	search.Parent = workspace
	player.Character:Destroy()
	player.Character = search	
	
		
	end)
end


game.Players.PlayerAdded:Connect(function(player)
	local CharacterValue = Instance.new("StringValue")
	CharacterValue.Parent = player
	CharacterValue.Value = "None"
	CharacterValue.Name = "CharacterValue"
	ChangeCharacter(player)
end)

EDIT: When the player chooses a character, it loads.

local function changeCharacter(player)
	local search = game:GetService("ReplicatedStorage"):FindFirstChild(player.CharacterValue.Value):Clone() --Find the custom character
	if search then --If the custom character exists
		search.Parent = workspace
		player.Character:Destroy()
		player.Character = search --Change it
	end
end

game:GetService("Players").PlayerAdded:Connect(function(player) --When played rjoins
	local CharacterValue = Instance.new("StringValue")
	CharacterValue.Value = "None"
	CharacterValue.Name = "CharacterValue" --Create a value in it
	CharacterValue.Parent = player
	player.CharacterAdded:Connect(function(char) --When the player spawns/respawns
		changeCharacter(player) --change it back.
	end)
end)

That should work, do you change the CharacterValue when you equip a different one?

Also, do you want the character to also be loaded after the player leaves and rejoins?

2 Likes

Sorry for the late response, i was doing something else.

Thanks for spending your time doing this for me, i really appreciate it.

Yes, that’s what i intend to do.

The player chooses their character again.

image

What does this error mean?

It is because the character will be added, so then it destroys the character and makes a new one. Then that new one fires the character added event, and makes a new one. So this loop repeats forever.

2 Likes

I believe it’s causing that error because when the character is added, it runs that function that destroy sthe current character and sets it to a new one, which causes the CharacterAdded event to run again, causing a loop that’ll never end, causing the error to happen.

I believe a fix for this would be to make check if player.Character is equal to the searched character or not

local function changeCharacter(player)
	local search = game:GetService("ReplicatedStorage"):FindFirstChild(player.CharacterValue.Value):Clone() --Find the custom character
	if search and player.Character ~= search then --If the custom character exists and character is not custom character
		search.Parent = workspace
		player.Character:Destroy()
		player.Character = search --Change it
	end
end

game:GetService("Players").PlayerAdded:Connect(function(player) --When played rjoins
	local CharacterValue = Instance.new("StringValue")
	CharacterValue.Value = "None"
	CharacterValue.Name = "CharacterValue" --Create a value in it
	CharacterValue.Parent = player
	player.CharacterAdded:Connect(function(char) --When the player spawns/respawns
		changeCharacter(player) --change it back.
	end)
end)

I’m going off of pure speculation so I’m not sure if this what has to be done

3 Likes

Yeah, I believe a way to solve this is to first change the character to the search, then destroy the old character, so it won’t fire infinitely.

Didn’t notice you changed the script (thought it’s a copy), so I removed mine (since was very similar)

This seemed to fix the that problem, but i’m not really sure what do do about this:

(When the player respawns)

test - Roblox Studio (gyazo.com)

The camera seems to be fixed in one position and the animations won’t play.

You need to set the subject of the current camera to the new humanoid through a remote event

2 Likes

Are there custom animations for the character?

A fix for the camera would be to set the camerasubject to the player, which in this case would probably just need to be

local function changeCharacter(player)
	local search = game:GetService("ReplicatedStorage"):FindFirstChild(player.CharacterValue.Value):Clone() --Find the custom character
	if search and player.Character ~= search then --If the custom character exists and character is not custom character
		search.Parent = workspace
		player.Character:Destroy()
		player.Character = search --Change it
		workspace.CurrentCamera.CameraSubject = player.Character:FindFirstChildOfClass("Humanoid") --Changed to FindFirstChildOfClass incase your humanoid is named differently
	end
end

game:GetService("Players").PlayerAdded:Connect(function(player) --When played rjoins
	local CharacterValue = Instance.new("StringValue")
	CharacterValue.Value = "None"
	CharacterValue.Name = "CharacterValue" --Create a value in it
	CharacterValue.Parent = player
	player.CharacterAdded:Connect(function(char) --When the player spawns/respawns
		changeCharacter(player) --change it back.
	end)
end)

If your character has a humanoid in it, which most definitely does, once it finds it, the currentcamera’s subject becomes the new character’s humanoid through this if I’m not mistaken

1 Like

It still seems to be causing the same problem. (The custom character is using the standard roblox animations through a local script)

(The Character in replicated storage)
image
There’s also another problem with the character not respawning.

What do you mean by the character not respawning?

The character sometimes isn’t respawning:

test - Roblox Studio (gyazo.com)

EDIT: Sorry for bothering you all, i just have no idea how to do things with the player’s character.

Were there any errors in the output?

Just the same errors: