01 | local function Activated() |
02 | if Toggled = = false then |
03 | Toggled = true |
04 | local animTrack 1 = Humanoid:LoadAnimation(Animation 1 ) |
05 | animTrack 1 :Play() |
06 | wait( 1.45 ) |
07 | local animTrack 2 = Humanoid:LoadAnimation(Animation 2 ) |
08 | animTrack 2 :Play() |
09 | wait( 29.95 ) |
10 | else |
11 | Toggled = false |
12 | local animTrack 3 = Humanoid:LoadAnimation(Animation 3 ) |
13 | animTrack 3 :Play() |
14 | wait( 1.25 ) |
15 | local ActiveTracks = Humanoid:GetPlayingAnimationTracks() |
This script was meant to make the character play an animation after the player presses the GUI button, but the player is still able to move while the animation is playing, is there some way i can make the player unable to move during the animations?
And if you can please give me a feedback of my script, any help is appreciated.
Hello! I learned this very recently and it should help you.
If you're using Roblox animation editor, you can add event marker by right clicking the black-ish bar above the keyframes. You can declare the event at the beginning and at the end of your animation, with your preferred argument (say, WalkSpeed).
To connect the function you declared, you use: AnimationTrack:GetMarkerReachedSignal("functionName"):Connect(function(argument) end)
Here is my example.
1 | loadedWalk:GetMarkerReachedSignal( "stepsound" ):Connect( function (sound) |
2 | local sound = 10 -- this is volume |
3 | FootstepSound.Volume = sound |
4 | FootstepSound:Play() |
5 | end ) |
For your situation, you can do
1 | animTrack:GMRS( "blabla" ):Cnct(fnct(arg) |
2 | if humanoid.WalkSpeed = (originalWalkspeed) then |
3 | humanoid.WalkSpeed = 0 |
4 | if humanoid.WalkSpeed = 0 then |
5 | humanoid.WalkSpeed = (originalWalkspeed) |
6 | end ) |
since your event triggers twice, I used if .. then to check if your humanoid can walk or has been stopped. Hope this helped :)