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

how do i run an animation in a while loop?

Asked by
Teeter11 281 Moderation Voter
9 years ago

so im trying to run an animation in a while loop but the animation just stops working and it doesnt work right

idk whats wrong but here is my code

local slash1 = Instance.new("Animation")
slash1.AnimationId = "http://www.roblox.com/Asset?ID=166956234"
local swordslash1 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(slash1)

function swordslash()
    print'animating'
    animating = true
    swordslash1:Play()
    wait(3)
    animating = false
end

animating = false
function update() 
    if script.Parent.Equipped.Value == "IronSword" then

        sword.BrickColor = BrickColor.new("Dark stone grey")
        mesh.MeshId = "rbxasset://fonts/sword.mesh"
        mesh.TextureId = ""

        if script.Parent.Button1DownValue.Value == true then
            if animating == false then
                swordslash()
            end
        end
    end
end

while wait() do
    update()
end

0
Look at line 15. Is that path right? You may one to change the StringValue's name because there is no Value of the Equipped Event, so that may interfere with the script. Shawnyg 4330 — 9y
0
this is inside of the gui not a tool if that is what you are thinking (im making an advanced tool system) Teeter11 281 — 9y

1 answer

Log in to vote
-1
Answered by 9 years ago

Is this in a LocalScript? Animations for player characters must be played from a Local Script to work. (http://wiki.roblox.com/index.php?title=Animations#Using_Animation_in_Games)

--MightyWanderer

0
Yes it is Teeter11 281 — 9y
0
Are there any errors, then? MightyWanderer 30 — 9y
Ad

Answer this question