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

How to make player unable to move during animation?

Asked by 5 years ago
01local function Activated()
02 if Toggled == false then
03   Toggled = true
04  local animTrack1 = Humanoid:LoadAnimation(Animation1)
05   animTrack1:Play()
06  wait(1.45)
07  local animTrack2 = Humanoid:LoadAnimation(Animation2)
08   animTrack2:Play()
09  wait(29.95)
10 else
11  Toggled = false
12  local animTrack3 = Humanoid:LoadAnimation(Animation3)
13   animTrack3:Play()
14  wait(1.25)
15  local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
View all 25 lines...

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.

1 answer

Log in to vote
0
Answered by
asgm 109
5 years ago

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.

1loadedWalk:GetMarkerReachedSignal("stepsound"):Connect(function(sound)
2    local sound = 10 -- this is volume
3    FootstepSound.Volume = sound
4    FootstepSound:Play()
5end)

For your situation, you can do

1animTrack:GMRS("blabla"):Cnct(fnct(arg)
2if humanoid.WalkSpeed = (originalWalkspeed) then
3    humanoid.WalkSpeed = 0
4if humanoid.WalkSpeed = 0 then
5    humanoid.WalkSpeed = (originalWalkspeed)
6end)

since your event triggers twice, I used if .. then to check if your humanoid can walk or has been stopped. Hope this helped :)

0
Edit : I didn't really look at your code cuz I'm lazy to do so. Sorry if this doesn't help! asgm 109 — 5y
0
It worked perfectly!Thank you so much! kevinsoaresv 47 — 5y
Ad

Answer this question