Default animations not working on custom player model

I’m running into an issue when replacing the player’s character model with a custom one. The replacement goes through just fine as the character’s model changes to the new rig. However, the default animations are not working even though this is a Roblox made rig.

I have checked the following:

  • I made sure to have the correct animation script in the new model (I copied the animation script from my live character in the test server).
  • There’s an animator class under Humanoid (manually created).
  • The HumanoidRootPart isn’t anchored.
  • The rig seems to be built correctly (I used Roblox’s Rig Builder to make the basic rig).

It’s interesting to note that when I place the model under StarterPlayer and name it StarterCharacter, The animations work normally. So I’m not entirely sure what I’m missing.

1 Like

If you want to replace the player’s model, I would suggest using the Player.CharacterAppearance property and/or Player/CharacterAppearanceLoaded event.
Player.CharacterAppearance is read-only, but you can change it using Player.CharacterAppearanceLoaded. It’s important that you use the event to change the appearance, because the property may not be set when your script is executed.
If you want to change the appearance of the player’s character and allow them to choose, you can use the Avatar Editor GUI button.

1 Like

How do you change the players character to the custom one? To me it sounds like the custom character is missing something that StarterCharacter automatically implements. Could you show us the script?

1 Like

@gurkleffe Here’s the script that I was using:

local package = script.Parent
local proxTrig = package.Primary.ProximityPrompt
local newModel = package.SpaceSuit

local connection = proxTrig.Triggered:Connect(function(player)
	local oldChar = player.Character
	local newChar = newModel:Clone()
	newChar.Name = player.Name
	newChar.Humanoid.DisplayName = player.DisplayName
	newChar.HumanoidRootPart.Anchored = false
	newChar.HumanoidRootPart.Position = oldChar.HumanoidRootPart.Position
	newChar.Parent = game.Workspace
	player.Character = newChar
	task.wait(0)
	game.ReplicatedStorage.Events.Camera:FireClient(player)
end)

print("Proximity prompt script executed")
print(connection.Connected)

I had to use the remote event to reset the player’s camera to the new character model so the camera would follow the new model.

@xDeltaXen I looked into that as you suggested, and that’s not going to work for my situation. The player’s character appearance is changed when they interact with an item that is using ProximityPrompt, so the appearance change is manually initiated by the player.

2 Likes

I think the problem is in the Animate LocalScript you took from playtesting not being compatible for some reason. If you clone the Animate LocalScript from the old character and put it into the new character, it works. I did this by simply adding

oldChar.Animate:Clone().Parent = newChar

Here’s the full code with it:

local package = script.Parent
local proxTrig = package.Primary.ProximityPrompt
local newModel = package.SpaceSuit

local connection = proxTrig.Triggered:Connect(function(player)
	local oldChar = player.Character
	local newChar = newModel:Clone()
	newChar.Name = player.Name
	newChar.Humanoid.DisplayName = player.DisplayName
	newChar.HumanoidRootPart.Anchored = false
	newChar.HumanoidRootPart.Position = oldChar.HumanoidRootPart.Position
	newChar.Parent = game.Workspace
	player.Character = newChar
	oldChar.Animate:Clone().Parent = newChar
	task.wait(0)
	game.ReplicatedStorage.Events.Camera:FireClient(player)
end)

print("Proximity prompt script executed")
print(connection.Connected)
1 Like

So you have to clone the script manually even though it’s part of the model. Interesting. Besides, I found a different method to do this more reliably. Here’s my new script:

--[[

Created by Maelstorm_1973

Interactive script for spacesuit model.  This handles the
ProximityPrompt triggered event to change the character's
appearence to that of the spacesuit.

--]]



-- ******** Requirements

-- Required Game Services and Facilities
local playerService = game:GetService("Players")



-- ******** Local Data

local package = script.Parent
local proxTrig = package.Primary.ProximityPrompt

-- Accessory table for the new character appearance.
local accessoryTable = {
	{
		-- Spacesuit
		Order = 1;
		AssetId = 11101290556;
		AccessoryType = Enum.AccessoryType.Pants
	};
	{
		-- Spacesuit Helmet
		Order = 1;
		AssetId = 11100983554;
		AccessoryType = Enum.AccessoryType.Hat
	};
}



-- ******** Event Handlers

-- Called when the player interacts with a proximity prompt.
proxTrig.Triggered:Connect(function(player)
	
	-- Change the player's appearance.
	local char = player.Character
	local human = char:FindFirstChild("Humanoid")
	player:ClearCharacterAppearance()
	local desc = human:GetAppliedDescription()
	desc:SetAccessories(accessoryTable, false)
	human:ApplyDescription(desc)
	
	-- Set a flag on the player to indicate the appearance
	-- has changed.
	local flag = Instance.new("BoolValue")
	flag.Name = "SpacesuitActive"
	flag.Value = true
	flag.Parent = player
	
	-- Removes the flag if/when the player dies.
	human.Died:Connect(function()
		flag:Destroy()
	end)
end)

This will actually change the character’s appearance without deleting the character and having to reset everything. I have to give credit to @xDeltaXen because his answer, although not the correct one, lead to me finding this method in Roblox’s documentation.

2 Likes

No, you-you are breathe taking

1 Like

Well, you can always check out my game and tell me what you think. It’s just the lobby and nothing happens after the selection process, but you can see where I’m going with it. There’s another part to it called The Proving Grounds which is under active code development. Just finished the CTF 4-Team combat mode. I’m going to work on the other modes before to long.

War!! Combat Team Arena

1 Like