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

Why wont these animations play?

Asked by
Chronomad 180
8 years ago

I have a script that should be cycling through a table of strings, and playing an animation based on which string is in the value at the time. Upon closer inspection, I found that the second value (DodgeAsset) Was not being changed for some reason. Any help is appreciated!


local C = script.Parent.Humanoid Left = ("http://www.roblox.com/Asset?ID=318876532") Right = ("http://www.roblox.com/Asset?ID=318875300") CenterOverhead = ("http://www.roblox.com/Asset?ID=326759151") LeftDodge = ("rbxassetid://326770084") RightDodge = ("rbxassetid://326769779") function ChooseAttack() local AttackList = {"Left","Right","CenterOverhead"} local A = script.Parent.DummyBrains.CombatValues.Asset while wait() do A.Value = AttackList[math.random(1, #AttackList)] end end function ReactAndDodge() local DodgeList = {"LeftDodge","RightDodge"} local A = script.Parent.DummyBrains.CombatValues.DodgeAsset while wait() do A.Value = DodgeList[math.random(1, #DodgeList)] end end function PlayAttack() local A = Instance.new("Animation") A.AnimationId = (script.Parent.DummyBrains.CombatValues.Asset.Value) local animTrack = C:LoadAnimation(A) animTrack:Play() end function PlayDodge() local A = Instance.new("Animation") A.AnimationId = (script.Parent.DummyBrains.CombatValues.DodgeAsset.Value) local animTrack = C:LoadAnimation(A) animTrack:Play() end while wait() do ChooseAttack() PlayAttack() wait(0.5) ReactAndDodge() PlayDodge() end
0
Yeah it's because you a thousand infinite while loops. NoahWillCode 370 — 8y

1 answer

Log in to vote
1
Answered by
Hero_ic 502 Moderation Voter
8 years ago

The way I do things is set every animation like this for example

local animation1 = Instance.new("Animation")
animation1.AnimationId = "rbxassetid://YOURNUMBERSHERE"

function playAnimation(Ani)
    local track = humanoid:LoadAnimation(Ani)
    track:stop()
    track:play()
end

playAimation(animation1)

There are way more efficient ways of doing this but this is what I most of the time do.

Ad

Answer this question