Animations are not playing

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I just want the character’s animation to play
  2. What is the issue? Include screenshots / videos if possible!
    Animations are not playing

I have this character selection system that clones a character from the replicated storage and set it manually as the player’s character. After setting the character and spawning it in the animations aren’t showing. The animations I am using are the default animations roblox provide with their animate script whenever you spawn a rig

image

My cloned character

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried setting the network ownership and using different rigs
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Server script

local RP = game:GetService("ReplicatedStorage")

local characters = RP.Characters
local remote = RP.Remotes.CharacterSelection

function SetCharacter(plr,charFolder)
	local oldChar = plr.Character
	local newChar = charFolder.Model.Character:Clone()
	newChar.Parent = game.Workspace
	newChar.Name = plr.DisplayName
	newChar:WaitForChild("HumanoidRootPart").CFrame = workspace:FindFirstChildOfClass("SpawnLocation") and workspace:FindFirstChildOfClass("SpawnLocation").CFrame or CFrame.new(0, 10, 0)

	
	plr.Character = newChar
	
	oldChar:Destroy()
	
	return newChar
end

function GiveStats(plr,charFolder)
	local statsFolder = charFolder.Stats:Clone()
	statsFolder.Parent = plr
	
	return statsFolder
end

function GiveHealth(newChar,statsFolder)
	local Health = Instance.new("IntValue")
	Health.Name = "Health"
	Health.Parent = newChar
	Health.Value = statsFolder.MaxHealth.Value
end

function GiveAlive(newChar,statsFolder)
	local Alive = Instance.new("BoolValue")
	Alive.Name = "Alive"
	Alive.Parent = newChar
	Alive.Value = true
end

function SetNetWorkOwnerShip(plr)
	plr.Character.HumanoidRootPart:SetNetworkOwner(plr)
end

remote.OnServerEvent:Connect(function(plr, charFolder)
	
	local newChar = SetCharacter(plr,charFolder)
	local statsFolder = GiveStats(plr,charFolder)
	GiveHealth(newChar,statsFolder)
	GiveAlive(newChar,statsFolder)
	SetNetWorkOwnerShip(plr)
	
	plr.Information.SelectedCharacter.Value = charFolder.Name
	
	remote:FireClient(plr,newChar)
end)

local script

wait(.5)
local RP = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local plr = Players.LocalPlayer

local characters = RP.Characters
local selectCharRemote = RP.Remotes.CharacterSelection

local camera = workspace.CurrentCamera

local prop = game.Workspace.CharacterSelectionProp

local charDesc = plr.PlayerGui.CharacterSelectionGui.CharacterDescriptionFrame
local charSelection = plr.PlayerGui.CharacterSelectionGui.CharacterSelectionFrame

local choseCharacter = nil

local charFolder

function SetUp()
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = prop.CameraPart.CFrame
	
	charDesc.Visible = true
	charSelection.Visible = true
end

function MakeButton()
	for i, item in pairs(characters:GetChildren()) do
		local newTemp = charSelection.ScrollingFrame.Content.Template:Clone()
		newTemp.Parent = charSelection.ScrollingFrame.Content
		newTemp.Name = item.Name
		newTemp.CharacterName.Text = item.Name
		newTemp.Visible = true
	end
end

function PreviewCharacter(charFolder)
	if choseCharacter ~= nil then
		prop:FindFirstChild("Preview"):Destroy()
	end
	
	local newChar = charFolder.Model.Character:Clone()
	newChar.Parent = prop
	newChar.Name = "Preview"
	newChar.PrimaryPart.CFrame = prop.CharacterPart.CFrame
	newChar.PrimaryPart.Anchored = true
end

function PreviewStats(charFolder)
	charDesc.Title.Text = charFolder.Name
	charDesc.Health.Text = "Max Health: "..tostring(charFolder.Stats.MaxHealth.Value)
	charDesc.BaseDamage.Text = "Base Damage: "..tostring(charFolder.Stats.BaseDamage.Value)
	charDesc.Speed.Text = "Speed: "..tostring(charFolder.Stats.Speed.Value)
end

if choseCharacter == nil then
	SetUp()
	MakeButton()
end


for i, item2 in pairs(charSelection.ScrollingFrame.Content:GetChildren()) do
	if item2.Name ~= "Template" and item2.Name ~= "UIGridLayout" then
		item2.MouseButton1Click:Connect(function()
			charFolder = characters:FindFirstChild(item2.Name)
			
			PreviewCharacter(charFolder)
			PreviewStats(charFolder)
						
			choseCharacter = item2.Name
		end)
	end
end

charDesc.SpawnButton.MouseButton1Click:Connect(function()
	if choseCharacter ~= nil then
		selectCharRemote:FireServer(charFolder,camera)
	end
end)

selectCharRemote.OnClientEvent:Connect(function(newChar)
	print(newChar.Humanoid.Parent)
	camera.CameraType = Enum.CameraType.Custom
	camera.CameraSubject = newChar.Humanoid
	
	charDesc.Visible = false
	charSelection.Visible = false
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Might sound stupid but try to convert that script to a server script, because local scripts only work under the player’s character and not custom ones (when in the workspace)

1 Like

You mean the default roblox animate script?

1 Like

Yes, just copy past into a server script with all the values

1 Like

After some trial and error, I discovered that local scripts couldn’t automatically run after being cloned inside a character from replicated storage. You would have to insert the local script into the cloned character again to make it start running.

Thanks, Tin for the help and suggested provided.

1 Like

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