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

How can i make an animation play like its a default?

i made animations like wald run etc. but how to i let them work a default for my game?

1 answer

I really do not know what you mean by "wald run" sorry. However, I understood that you made an animation and want it to play when player is running all the time I assume. It would be preferable for you to also create an idle animation (when player is not moving) but it is not neccessary. So you should create a script in ServerScriptService and write the following:

game.Players.PlayerAdded:Connect(function(player)
	local char = player.Character
	local hum = char:WaitForChild("Humanoid")
	hum.Running:Connect(function(speed)
		local anim = Instance.new("Animation")
		if speed > 0 then
			anim.AnimationId = "rbxassetid://12345" -- 12345 must be changed to your Running Animation Id
			local animTrack = hum:LoadAnimation(anim)
			animTrack:Play()
		elseif speed <= 0 then
			anim.AnimationId = "rbxassetid://12345" -- 12345 must be changed to Idle Animation Id
			local animTrack = hum:LoadAnimation(anim)
			animTrack:Play()
		end
	end)
end)
			

In this we have used the Running Event http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Running and the speed variable stores the speed of the player at so you can monitor it for your purposes. The elseif speed <= 0 doesn't have to be included but is recommended so your game looks better

2 comments

0

thx thx thx

0

ok can you please say that this answer is accepted

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