Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

2 comments

0

sorry if im unclear

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

This discussion is preserved as it was. New answers, comments, and votes are closed.