Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is it possible to make player play an animation on clicking a brick?

so i dont want anyone to write me a script or animate anything, im just wondering it is possible.

k so ive got this script


script.Parent.ClickDetector.MouseClick:connect(function(player)
    local leftMouseDown = true
    player:GetMouse().Button1Up:connect(function() 
        leftMouseDown = false 
    end)
	wait(1)
    while leftMouseDown do	
        player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 10 
        wait(1)
    end
end)

would it be possible to within the

    while leftMouseDown do	
        player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 10 
        wait(1)
    end

Part add a player animation. ill explain

this is going to be a very basic fishing system and it works by holding your mouse button down on the fishing hole. and im wanting to to play an animation of holding a pole, i can make the animation and such but im wondering if this is even possible to do b4 i try.

1 answer

✓ Accepted answer

Once you have the Animation you can Play it like so:

animationTrack = player.Character.Humanoid:LoadAnimation(*Enter Animation Instance Here*)
animationTrack:Play()

You could have the Animation Instance located in the script (I.E have the script as its Parent) You can then play it like so:

animationTrack = player.Character.Humanoid:LoadAnimation(script.FishingAnimation)
animationTrack:Play()

So, yes it is possible. The "LoadAnimation" function returns an "AnimationTrack" object which you can then play.

http://wiki.roblox.com/index.php?title=API:Class/AnimationTrack http://wiki.roblox.com/index.php?title=API:Class/Humanoid

1 comment

0

thanks for the nice answer, was worried at first when i checked animations wiki all i saw about player animations was it had to be in a local script. which i couldnt do on my brick

This discussion is preserved as it was. New answers, comments, and votes are closed.