Hello,
I have a problem, my custom character does not play the animations, you will find in first the script for animations, then when the player deploy as the custom character.
Localscript (named “Animate” in the character):
local rf = game:GetService("ReplicatedFirst")
local RS = game:GetService("RunService")
local plr = game:GetService("Players").LocalPlayer
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local function loadanimation(anim)
return humanoid.Animator:LoadAnimation(anim)
end
if (humanoid) then
local walkAnim = script:WaitForChild("Walk")
local walkAnimTrack = loadanimation(walkAnim)
local pauseAnim = script:WaitForChild("Pause")
local pauseAnimTrack = loadanimation(pauseAnim)
humanoid.Running:Connect(function(speed)
if speed > 0 then
if pauseAnimTrack.IsPlaying then
pauseAnimTrack:Stop()
end
if not walkAnimTrack.IsPlaying then
walkAnimTrack:Play()
end
else
if walkAnimTrack.IsPlaying then
walkAnimTrack:Stop()
end
if not pauseAnimTrack.IsPlaying then
pauseAnimTrack:Play()
end
end
end)
end
Script (fired once the player click on a button):
local rs = game:GetService("ReplicatedStorage")
local event = rs.Events.UI.MainMenu.Deploy
event.OnServerEvent:Connect(function(plr)
local char = plr.Character
local oldPosition = char.PrimaryPart
local newCharacter = game:GetService("ReplicatedFirst")["Character Manager"].Character:Clone()
local newAnimate = game:GetService("ReplicatedFirst")["Character Manager"].AnimatorCharacter:Clone()
newAnimate.Name = "Animate"
newCharacter.Name = plr.Name
newCharacter:PivotTo(oldPosition.CFrame)
char:Destroy()
plr.Character = newCharacter
char = plr.Character
newCharacter.Parent = workspace
newAnimate.Parent = newCharacter
local humanoid = newCharacter.Humanoid
event:FireClient(plr, humanoid)
end)