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

How to make a animation stop when a player moves and restart when he stops moving?

Asked by 3 years ago
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local char = player.Character
local hum = char.Humanoid
local running = false
local UIS = game:GetService("UserInputService")
local ToggleSusanoo = game.ReplicatedStorage:WaitForChild("ToggleSusanoo")

UIS.InputBegan:Connect(function(Input, Chat)
    if Input.KeyCode == Enum.KeyCode.E and not Chat and hum.Health >= 1 then
        if running == false then
            ToggleSusanoo:FireServer(true)
            local Anim = Instance.new('Animation')
            Anim.AnimationId = script.Idle.AnimationId
            PlayAnim = char.Humanoid:LoadAnimation(Anim)
            PlayAnim:Play()

            running = true
        elseif running == true then
            ToggleSusanoo:FireServer(false)
            PlayAnim:Stop()
            running = false
        elseif running == true then

            if hum.walkspeed > 0 then

                PlayAnim:Stop() 
        end




        end
    end
end)

this is the script and i tried to make it so when the walspeed is bigger than 0 the animation stops but it didnt work

1 answer

Log in to vote
0
Answered by 3 years ago

PLay test your game, open explorer while play testing, open workspace, open your player model inside will be a script called "Animate" copy that. stop the play test, paste it into StarterCharacterScripts in StarterPlayerScripts, replace the idle animation id's with the id of your animation..

0
sorry if im unclear popeofscandinavia -1 — 3y
0
yeah ik that but i wanna make it so when i hit the button my idle animation changes i tried to do it like that but didnt work soreno2468 31 — 3y
Ad

Answer this question