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

Why is the animation not firing?

Asked by 8 years ago

Please help, I commented in the part of the script with the animation in it.

Parent = script.Parent
enabled = false
-- Variables

Parent.Touched:connect(function(hit)
    player = game.Players:GetPlayerFromCharacter(hit.Parent)
    wait()
    if not enabled and hit.Parent ~= nil then
        enabled = true
        if not player and hit ~= nil and (hit.Parent.Name ~= "Zombie") then
            if hit.Parent:FindFirstChild("Humanoid") then
                hit.Parent:WaitForChild("Humanoid").Health = hit.Parent:WaitForChild("Humanoid").Health - 20
                local AnimController = Instance.new("AnimationController") 
                AnimController.Parent = script.Parent.Parent
                local animation = Instance.new("Animation")
                animation.AnimationId = "http://www.roblox.com/asset?ID=298235328"
                animation.Parent = script.Parent.Parent.Humanoid
                local animTrack = AnimController:LoadAnimation(animation)
                animTrack:Play() -- play anime
                wait(0.5)
                animTrack:Stop() -- stop anime(because this one is looped)
            end
        elseif player and player.TeamColor ~= BrickColor.new("Black") then
                if hit.Parent:FindFirstChild("Humanoid") then
                hit.Parent:WaitForChild("Humanoid").Health = hit.Parent:WaitForChild("Humanoid").Health - 20
                local AnimController = Instance.new("AnimationController")
                AnimController.Parent = script.Parent.Parent
                local animation = Instance.new("Animation")
                animation.AnimationId = "http://www.roblox.com/asset?ID=298235328"
                animation.Parent = script.Parent.Parent.Humanoid
                local animTrack = AnimController:LoadAnimation(animation)
                animTrack:Play() -- play anime
                wait(0.5)
                animTrack:Stop() -- stop anime(because this one is looped)
            end
        end
    end
    wait(3)
    enabled = false
end)Parent = script.Parent
enabled = false
-- Variables

Parent.Touched:connect(function(hit)
    player = game.Players:GetPlayerFromCharacter(hit.Parent)
    wait()
    if not enabled and hit.Parent ~= nil then
        enabled = true
        if not player and hit ~= nil and (hit.Parent.Name ~= "LMADer") and (hit.Parent.Name ~= "BC") and (hit.Parent.Name ~= "SuicideBomber") and (hit.Parent.Name ~= "FastRobloxian") and (hit.Parent.Name ~= "KorbloxianKnight") and (hit.Parent.Name ~= "OBC") and (hit.Parent.Name ~= "ODer") and (hit.Parent.Name ~= "RobloxianR") and (hit.Parent.Name ~= "TBC") and (hit.Parent.Name ~= "Traitor") and (hit.Parent.Name ~= " Zombie") and (hit.Parent.Name ~= "Zombie ") and (hit.Parent.Name ~= "Zombie") and hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Humanoid").Health > 0 then
            if hit.Parent:FindFirstChild("Humanoid") then
                hit.Parent:WaitForChild("Humanoid").Health = hit.Parent:WaitForChild("Humanoid").Health - 20
                local AnimController = Instance.new("AnimationController") -- Need help here
                AnimController.Parent = script.Parent.Parent -- Need help here
                local animation = Instance.new("Animation") -- Need help here
                animation.AnimationId = "http://www.roblox.com/asset?ID=298235328" -- Need help here
                animation.Parent = script.Parent.Parent.Humanoid -- Need help here
                local animTrack = AnimController:LoadAnimation(animation) -- Need help here
                animTrack:Play() -- play anime
                wait(0.5) -- Need help here
                animTrack:Stop() -- stop anime(because this one is looped) -- Need help here
            end
        elseif player and player.TeamColor ~= BrickColor.new("Black") then
                if hit.Parent:FindFirstChild("Humanoid") then
                hit.Parent:WaitForChild("Humanoid").Health = hit.Parent:WaitForChild("Humanoid").Health - 20
                local AnimController = Instance.new("AnimationController") -- Need help here
                AnimController.Parent = script.Parent.Parent -- Need help here
                local animation = Instance.new("Animation") -- Need help here
                animation.AnimationId = "http://www.roblox.com/asset?ID=298235328" -- Need help here
                animation.Parent = script.Parent.Parent.Humanoid -- Need help here
                local animTrack = AnimController:LoadAnimation(animation) -- Need help here
                animTrack:Play() -- play anime
                wait(0.5) -- Need help here
                animTrack:Stop() -- stop anime(because this one is looped) -- Need help here
            end
        end
    end
    wait(3)
    enabled = false
end)

Please note that I do have a working humanoidrootpart present in the model. Also, there is another animation(walking) that is playing, how can I cancel out that animation and fire this one instead?

0
Is it a walking anim? You can get free models that do it for you :) TheDeadlyPanther 2460 — 8y
0
@TheDeadlyPanther Did you just say "free models?" Nobody better say that word in this forum ever (besides if you're going to study off one c:) groovydino 2 — 8y

Answer this question