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

Animation not working?

Asked by 8 years ago

I made a test animation and for some reason it does not work.It does not return anything in the output.Could anyone help?

local mouse = game.Players.LocalPlayer:GetMouse()
local running = false
anim=Instance.new("Animation",workspace)
anim.AnimationId = "http://www.roblox.com/Asset?ID=291317454"


function bazinga()  
    for _, idk in ipairs(script.Parent:GetChildren()) do
        if idk.className == "Tool" then return idk end
    end
    return nil
end


mouse.KeyDown:connect(function (key) -- Run function
    key = string.lower(key)
    if string.byte(key) == 114 then
        running = true
    local t=workspace:FindFirstChild("HumanoidRootPart"):clone()        
    t.Parent=workspace:FindFirstChild("Player")
    local animTrack = workspace:WaitForChild("Player").Humanoid:LoadAnimation(anim)
    animTrack:Play()    
    local br=game.lighting.ParticleEmitter:clone()
    br.Parent=game.Players.LocalPlayer.Character.Torso
        end
    end)
0
Player already have HumanoidRootParts you dont need to clone one. neoG457 315 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Like neo said, do not clone the HumanoidRootPart, now it seems that the script gets stuck on workspace:WaitForChild. There are a few things you can do. First, see if FindFirstChild does anything or prints anything to the output. If it does, either Player doesn't exist or has not loaded in time. I would high recommend making this a local script if not already done so and setting Player to game.Players.LocalPlayer. Then just replace line 21 with Player.Character.Humanoid:LoadAnimation(anim)

--Use a local script

--add this to your variable list at the beginnning of the script
Player = game.Players.LocalPlayer

--line 21 with this || Try WaitForChild("Character") if this doesn't find Player.Character
Player.Character.Humanoid:LoadAnimation(anim)

Please let me know if this doesn't work, but I'm quite sure that line 21 is causing the error, nothing else seems to be wrong or would prevent the animation at least...

Ad

Answer this question