Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[Solved] Why aren't animations replicating with my custom character?

Asked by 4 years ago
Edited 4 years ago

Hi, so I'm trying to make something that allows someone to have an r6 hitbox, while keeping their R15 appearance and animations. To do this, I've made their character R6, made them invisible, made a copy of what their actual R15 character should look like, welded their root parts together, and put the R15 rig inside of their character (as a child), and finally I modified the animation script so it would play the animations on the fake r15 character instead. The modified animation script is too long to post here, but the server-side script isn't too long.

local function newchar(plr)
    local uid = plr.UserId
    local charinfo = game:GetService("Players"):GetCharacterAppearanceInfoAsync(uid)
    local avatartype = charinfo.playerAvatarType

    if avatartype == "R6" then
        plr:LoadCharacter()
        if not plr.Character then
            plr.CharacterAdded:Wait()
        end
        local connection
        connection = plr.Character:WaitForChild("Humanoid").Died:Connect(function()
            connection:Disconnect()
            newchar(plr)
        end)
    elseif avatartype == "R15" then
        local char = game:GetService("ServerStorage").CustomChar:Clone()
        char.Name = plr.Name
        char.Parent = workspace
        plr.Character = char
        local humdesc = game:GetService("Players"):GetHumanoidDescriptionFromUserId(uid)
        -- Makes the character invisible
        plr:ClearCharacterAppearance()
        for i,v in pairs(char:GetChildren()) do
            if v:IsA("Part") then
                -- Removes meshes that may cause a problem in the next step
                for i2,v2 in pairs(v:GetChildren()) do
                    if v2:IsA("BlockMesh") or v2:IsA("SpecialMesh") then
                        v2:Destroy()
                    end
                end
                -- Makes invisible
                Instance.new("SpecialMesh", v).Scale = Vector3.new(0,0,0)
                -- Hide name
                char.Head.Transparency = 1
            end
        end
        local fchar = game:GetService("ServerStorage").R15:Clone()
        fchar.Name = plr.Name
        fchar.Parent = game:GetService("ServerStorage").Temp
        fchar.Humanoid:ApplyDescription(humdesc)
        for i,v in pairs(fchar:GetChildren()) do
            if v:IsA("BasePart") then
                game:GetService("PhysicsService"):SetPartCollisionGroup(v, "NonCollidable")
            end
        end
        fchar.Humanoid.PlatformStand = true
        fchar.Parent = char
        local weld = Instance.new("Weld")
        weld.Part0 = char.HumanoidRootPart
        weld.Part1 = char[plr.Name].HumanoidRootPart
        weld.C0 = CFrame.new(0,char[plr.Name].Humanoid.HipHeight-2,0)
        weld.Parent = char.HumanoidRootPart
        local connection
        connection = char.Humanoid.Died:Connect(function()
            connection:Disconnect()
            newchar(plr)
        end)
        for i,v in pairs(fchar:GetChildren()) do
            if v:IsA("BasePart") then
                v:SetNetworkOwner(plr)
            end
        end
    end
end
game:GetService("Players").PlayerAdded:Connect(newchar)

the place is here by the way (it's uncopylocked so you can view it in studio).

oh also I'm just looking for any suggestions on what I could try in order to fix it.

Thanks

1 answer

Log in to vote
0
Answered by 4 years ago

Nobody else will likely see this, but I might aswell answer my question. I've found out that inorder for an animation to be displayed, an animator must be inside of the humanoid. If a script tries to load an animation without it, it creates one inside of the humanoid. It should be well known that if a local script tries to create this animator, it won't be replicated to the server and therefore there won't be an animation displayed to other players. The solution is to create an animator from the server before trying to animate from the client.

Ad

Answer this question