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

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

Asked by
nicros 165
8 years ago

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

Log in to vote
1
Answered by 8 years ago

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

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 nicros 165 — 8y
Ad

Answer this question