Animation not playing from script. Help!

Hi, I have an issue running an animation in my script.
I did all the steps, I published the animation and using the code I’m trying to make a new animation instance and play it.
The issue is extremely strange, the first time i left click (which is when the animation is supposed to play) my character explodes.
After i respawn and try left clicking again i get the error: Cannot load the AnimationClipProvider Service I have no idea what black magic i conjured with my code but it would be great if someone could help me out.

uis.InputBegan:Connect(function(input, gameProcessedEvent)
    if not gameProcessedEvent then
        ...
        elseif input.UserInputType == basicAttack then
            print("m1")
            cmbtModule.attackFunc(Player, character, humanoid, hrp)

COMBATMODULE: 

combatModule.attackFunc = 
    function(player, character, humanoid, hrp)
        humanoid.RigType = "R6"

        local animator = character.Humanoid:WaitForChild("Animator")
        local swingAnim = Instance.new("Animation")
        swingAnim.AnimationId = "rbxassetid://13801385573"
         local swingAnimTrack = animator:LoadAnimation(swingAnim)
        swingAnimTrack:Play()
        print(humanoid.RigType)
        
    end

it does print R6 at the last print statement so my humanoid argument is correct.
Thanks in advance

7 Likes

If you want the entire code I can post it.

1 Like

Its not “Animator” its “Animate”, I don’t know where animator came from.

2 Likes

I looked it up in the documentation, and its definently animator that that i need to use here… also if i change it to animate it gives Infinite yield possible on ‘Ginney103.Humanoid:WaitForChild(“Animate”)’. Am i misinterpreting?

1 Like

also the issue persists even when i change animation and don’t use the animator

combatModule.attackFunc = 
    function(player, character, humanoid, hrp)
        humanoid.RigType = "R6"
        
        local animation = Instance.new("Animation")
        animation.AnimationId = "http://www.roblox.com/asset/?id=507771019" -- Roblox dance emote

        local animationTrack = humanoid:LoadAnimation(animation)
        animationTrack:Play()
        --local animator = character.Humanoid:WaitForChild("Animate")
        --local swingAnim = Instance.new("Animation")
        --swingAnim.AnimationId = "rbxassetid://13801385573"
     --    local swingAnimTrack = animator:LoadAnimation(swingAnim)
        --swingAnimTrack:Play()
        --print(humanoid.RigType)
        
    end
1 Like

Is this a localscript or serverscript

1 Like

It’s a modulescript being run from a localscript.

1 Like

Does your character explode literally or joints of your character just break? Just asking because i can’t seem to get the punchline of this ‘joke’.

1 Like

HP goes to zero, should maybe not have phrased it as “explode”.

1 Like

thats because you set character rigtype to r6 through script manually that happens when you do that through a script

1 Like

Delete a line

 humanoid.RigType = "R6"

that’s why your character is dying, because if for example you have r15 rig then there wouldn’t be joints to sustain the r6 rig, same goes for r6. Also if you wish to set a r6 avatar for all new players, you’ll have to do it in game settings manually. But allas if you even read this post, heres a script:

local newjoint=Instance.new('Motor6D')

function ConvertToR6(Character:Model)
local JointTable={}
local hrp=Character:FindFirstChild('HumanoidRootPart')
local torso=hrp:Clone()
torso.Name='Torso'
torso.CFrame=hrp.CFrame
torso.Parent=Character
local torsojoint=newjoint:Clone()
torsojoint.Parent=hrp
torsojoint.Part0=hrp
torsojoint.Part1=torso
torsojoint.C1=CFrame.new(0,0,0)*CFrame.Angles(math.rad(-90),math.rad(-180),0)
local ra=Instance.new('Part',Character)
ra.Name='Right Arm'
ra.CFrame=hrp.CFrame
ra.Size=Vector3.new(1, 2, 1)
local rightarm = newjoint:Clone()
rightarm.Name="Right Shoulder"
rightarm.Part0=torso
rightarm.Part1=ra
rightarm.C1=CFrame.new(-0.5,0.5,0)*CFrame.Angles(0,math.rad(90),0)
rightarm.C0=CFrame.new(1,0.5,0)*CFrame.Angles(0,math.rad(90),0)


local la=Instance.new('Part',Character)
la.Name='Left Arm'
la.CFrame=hrp.CFrame
la.Size=Vector3.new(1, 2, 1)
local leftarm = newjoint:Clone()
leftarm.Name="Left Shoulder"
leftarm.Part0=torso
leftarm.Part1=la
leftarm.C1=CFrame.new(0.5,0.5,0)*CFrame.Angles(0,math.rad(-90),0)
leftarm.C0=CFrame.new(-1,0.5,0)*CFrame.Angles(0,math.rad(-90),0)

local ll=Instance.new('Part',Character)
ll.Name='Left Leg'
ll.CFrame=hrp.CFrame
ll.Size=Vector3.new(1, 2, 1)
local leftleg = newjoint:Clone()
leftleg.Name="Left Hip"
leftleg.Part0=torso
leftleg.Part1=ll
leftleg.C1=CFrame.new(-0.5,1,0)*CFrame.Angles(0,math.rad(-90),0)
leftleg.C0=CFrame.new(-1,-1,0)*CFrame.Angles(0,math.rad(-90),0)

local rl=Instance.new('Part',Character)
rl.Name='Right Leg'
rl.CFrame=hrp.CFrame
rl.Size=Vector3.new(1, 2, 1)
local rightleg = newjoint:Clone()
rightleg.Name="Right Hip"
rightleg.Part0=torso
rightleg.Part1=rl
rightleg.C1=CFrame.new(0.5,1,0)*CFrame.Angles(0,math.rad(90),0)
leftleg.C0=CFrame.new(1,-1,0)*CFrame.Angles(0,math.rad(90),0)

local head=Character:FindFirstChild('Head')
local neck = newjoint:Clone()
neck.Name="Neck"
neck.Part0=torso
neck.Part1=head
neck.C1=CFrame.new(0,-0.5,0)*CFrame.Angles(math.rad(-90),math.rad(-180),0)
neck.C0=CFrame.new(0,1,0)*CFrame.Angles(math.rad(-90),math.rad(-180),0)
table.insert(JointTable,torso)
table.insert(JointTable,hrp)
table.insert(JointTable,rl)
table.insert(JointTable,ll)
table.insert(JointTable,la)
table.insert(JointTable,ra)
table.insert(JointTable,head)
for i,v in pairs(Character:GetChildren()) do 
if not table.find(JointTable,v,1) and (v:IsA('Part')) or (v:IsA('MeshPart')) then
v:Destroy()
end
end
end
5 Likes

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