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

How do i make a run animation play when The player has begun running?

So I made a Shift to run script, yet I am kind of stuck on something. How do I make an animation play when the player has begun running?

Heres the script:

`> local UserInputService = game:GetService("UserInputService")

local Character = script.Parent local Humanoid = Character:WaitForChild("Humanoid") local isRunning = false local runanim = game.ServerStorage.anims.Animation

UserInputService.InputBegan:Connect(function(key) if key.KeyCode == Enum.KeyCode.LeftShift then if not isRunning then isRunning = true Humanoid.WalkSpeed = 32 runanim:Play() else Humanoid.WalkSpeed = 16 runanim:Stop() isRunning = false end end end)`

Someone please help me with this, i think that it is the runanim:Play() / runanim:Stop() parts, yet i need something to confirm this for me or send me a fixed version of the script, Thanks for reading.

1 answer

the script works fine, you just need to change something, make the script to script and not a local script and put it in serverscriptservice

and change these

local runanim = game.ServerStorage.anims.Animation
local clone = runanime:Clone()

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		UserInputService.InputBegan:Connect(function(input, gameProcessed)
			if input.KeyCode == Enum.KeyCode.LeftShift then
				if gameProcessed then
					character.Humanoid.WalkSpeed = 32
					runanim.Parent = character.Humanoid
					local loader = character.Humanoid.runanim:LoadAnimation()
					loader:Play()
				else
					character.Humanoid.WalkSpeed = 16
					loader:Stop()
				end
			end
		end)
	end)
end)

idk if this is gonna work but if it does then have a great day!

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