I have a script that changes the player’s character on join (Depending on what character they have equipped) But when the character gets loaded the animations doesn’t work.
Function that changes character:
local function respawnPlayer(plr, modelName)
local model = game:GetService("ServerStorage"):WaitForChild("Characters"):FindFirstChild(modelName)
print("Model from server is", model)
local oldModel = plr.Character
local newModel = model:Clone()
newModel.Humanoid.WalkSpeed = 10;
newModel.Humanoid.JumpPower = 0;
newModel:SetPrimaryPartCFrame(oldModel.PrimaryPart.CFrame)
local Animate = script:WaitForChild("Animate"):Clone()
Animate.Parent = newModel
Animate.Disabled = false
for _, v in pairs(oldModel:GetChildren()) do
if v:IsA("Script") then
if not newModel:FindFirstChild(v.Name) then
v:Clone().Parent = newModel
end
end
end
newModel.Name = plr.Name
plr.Character = newModel
newModel.Parent = workspace
end