local Oldhumanoid = game.Workspace:FindFirstChild("DancingRig").Humanoid --Replace with pathway to Humanoid of the NPC.
local localPlayer = game.Players.LocalPlayer
local function applyAppearance()
local humanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(localPlayer.UserId)
task.wait(0.5)
local Newhumanoid = Oldhumanoid:Clone()
Newhumanoid.Parent = game.Workspace:FindFirstChild("DancingRig")
Oldhumanoid:Destroy()
Newhumanoid:ApplyDescription(humanoidDescription)
end
applyAppearance()
you can save a playerâs character to repstorage on join.
have a part in repstorage named âDancePositionâ and position it and rotate it for the new rig to be spawned in
Serverscript in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local newchar = character:Clone()
newchar.Parent = game:GetService("ReplicatedStorage")
local animation = Instance.new("Animation", newchar)
animation.Name = "Dance"
animation.AnimationId = (animid)
newchar:PivotTo(game:GetService("ReplicatedStorage").DancePosition.CFrame
for _, v in pairs(newchar:GetDescendants()) do
if v:IsA("BaseScript") then
v:Destroy()
end
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
game:GetService("ReplicatedStorage"):FindFirstChild(player.Name):Destroy()
end)
Localscript in StarterCharacterScripts
local player = game.Players.LocalPlayer
local character = game:GetService("ReplicatedStorage"):FindFirstChild(player.Name)
function loadchar()
character.Parent = workspace
character.Humanoid:LoadAnimation(character.Dance):Play()
end
loadchar()
make sure that you set parent back to repstorage when finished the scene
This will cause all clients to run this animation, which is not recommended. As animations are related to the humanoid Animator creation by the server
Instead, if you use the method that I have with a dance animation and do:
local Oldhumanoid = game.Workspace:FindFirstChild("DancingRig").Humanoid --Replace with pathway to Humanoid of the NPC.
local localPlayer = game.Players.LocalPlayer
local Animation = nil -- Put animation path here
local function applyAppearance()
local humanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(localPlayer.UserId)
task.wait(0.5)
local Newhumanoid = Oldhumanoid:Clone()
Newhumanoid.Parent = game.Workspace:FindFirstChild("DancingRig")
Oldhumanoid:Destroy()
if Newhumanoid:FindFirstChild("Animator") then
Newhumanoid:FindFirstChild("Animator"):Destroy()
end
local Animator = Instance.new("Animator", Newhumanoid)
Newhumanoid:ApplyDescription(humanoidDescription)
Newhumanoid:LoadAnimation(Animation):Play()
end
applyAppearance()
That will make it run on the client only, because of a new client ran humanoid Animator
Still wonât work. Here is one of my posts where I learned animations are replicated to the server based on the animation controller as seen here. the same is applied with the deprecation of loading animations with humanoid
In order to make local animations, the animator must be destroyed and remade on the client. Because by default they will replicate to the server
you can save a playerâs character to repstorage on join.
have a part in repstorage named âDancePositionâ and position it and rotate it for the new rig to be spawned in
Serverscript in ServerScriptService:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local newchar = character:Clone()
newchar.Parent = game:GetService("ReplicatedStorage")
local animation = Instance.new("Animation", newchar)
animation.Name = "Dance"
animation.AnimationId = (animid)
newchar:PivotTo(game:GetService("ReplicatedStorage").DancePosition.CFrame
for _, v in pairs(newchar:GetDescendants()) do
if v:IsA("BaseScript") then
v:Destroy()
end
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
game:GetService("ReplicatedStorage"):FindFirstChild(player.Name):Destroy()
end)
Localscript in StarterCharacterScripts
local player = game.Players.LocalPlayer
local character = game:GetService("ReplicatedStorage"):FindFirstChild(player.Name)
function loadchar()
character.Parent = workspace
if character.Humanoid:FindFirstChild("Animator") then
character.Humanoid.Animator:Destroy()
end
Instance.new("Animator", character.Humanoid)
character.Humanoid:LoadAnimation(character.Dance):Play()
end
loadchar()
make sure that you set parent back to repstorage when finished the scene