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
6 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

local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()

local S = game.Workspace.Seated
S.AnimationId = "http://www.roblox.com/asset/?id=933369397"

local SU = game.Workspace.StandingUp
SU.AnimationId = "http://www.roblox.com/asset/?id=935753167" 

mouse.KeyDown:connect(function(key)
    if key == "x" then 
        local player S = humanoid:Animation(S)
        S:Stop()
        local playAnim = humanoid:LoadAnimation(SU)
        playAnim:Play()
        wait(2)
        player.Character.Humanoid.WalkSpeed = 16

    end
end)
0
On line 14 it you needed to do local player = humanoid:LoadAnimation(S) saSlol2436 716 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Very minor fixes

local player = game.Players.LocalPlayer
local humanoid = player.Character.Humanoid
repeat wait() until humanoid
local mouse = player:GetMouse()
local Seat = workspace.Seated --You could do workspace instead game.Workspace
S.AnimationId = "http://www.roblox.com/asset/?id=933369397"

local SU = workspace.StandingUp -- Same thing here
SU.AnimationId = "http://www.roblox.com/asset/?id=935753167" 

mouse.KeyDown:Connect(function(key) --connect is depricated I reccommend  Connect
    if key == "x" then 
        local S = humanoid:LoadAnimation(S) -- On your script that you showed me the variable had a space plus I changed the name
        S:Stop()
        local playAnim = humanoid:LoadAnimation(SU)
        playAnim:Play()
        wait(2)
        humanoid.WalkSpeed = 16

    end
end)

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 — 6y
0
Oh idk how saSlol2436 716 — 6y
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 — 6y
Ad

Answer this question