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

Why doesn't my Looped Animation stop OnKeyDown?

Asked by
Kimuyo 13
7 years ago

when the player presses z they are seated and when they press x they play a standing up animation that leads into the idle animation

problem is the seated animation is looped and i don't know how to stop the Seated animation

01local player = game.Players.LocalPlayer
02repeat wait() until player.Character.Humanoid
03local humanoid = player.Character.Humanoid
04local mouse = player:GetMouse()
05 
06local S = game.Workspace.Seated
08 
09local SU = game.Workspace.StandingUp
11 
12mouse.KeyDown:connect(function(key)
13    if key == "x" then
14        local player S = humanoid:Animation(S)
15        S:Stop()
View all 22 lines...
0
On line 14 it you needed to do local player = humanoid:LoadAnimation(S) saSlol2436 716 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Very minor fixes

01local player = game.Players.LocalPlayer
02local humanoid = player.Character.Humanoid
03repeat wait() until humanoid
04local mouse = player:GetMouse()
05local Seat = workspace.Seated --You could do workspace instead game.Workspace
07 
08local SU = workspace.StandingUp -- Same thing here
10 
11mouse.KeyDown:Connect(function(key) --connect is depricated I reccommend  Connect
12    if key == "x" then
13        local S = humanoid:LoadAnimation(S) -- On your script that you showed me the variable had a space plus I changed the name
14        S:Stop()
15        local playAnim = humanoid:LoadAnimation(SU)
View all 21 lines...

Hopefully this helped you fix the script that you made :)

0
It mostly works but the looped seated animation doesn't stop when I press x Kimuyo 13 — 7y
0
Oh idk how saSlol2436 716 — 7y
0
Well you can make a gui go to the player gui by touching a part then make an if statment if the screenGui parent is playerGui and probably do the if key == "x" then the rest of the code saSlol2436 716 — 7y
Ad

Answer this question