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

what is the fastest way to update animations?

i am trying to update my walk animation everytime a certain button is pressed, but it takes like 2-3 seconds to start/stop and i have to do some messing around for it to work, iss there a way it can instantly play the walk animation?

--running
running = false
game:GetService('UserInputService').InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftControl and running == false then
		running = true
		walk.AnimationId = 'http://www.roblox.com/asset/?id=476653440'
		humanoid.WalkSpeed = 40
	elseif input.KeyCode == Enum.KeyCode.LeftControl and running == true then
		running = false
		walk.AnimationId = 'http://www.roblox.com/asset/?id=476341652'
		humanoid.WalkSpeed = 16
		
	end
end)


1 answer

You should load your two animations as separate animations rather than trying to change one.

local walkingAnimation = Instance.new("Animation")
walkingAnimation.AnimationId = "http://www.roblox.com/asset/?id=476341652"
local walkingAnimTrack = humanoid:LoadAnimation(walkingAnimation)

local runningAnimation = Instance.new("Animation")
runningAnimation.AnimationId = "http://www.roblox.com/asset/?id=476653440"
local runningAnimTrack = humanoid:LoadAnimation(runningAnimation)

running = false
game:GetService('UserInputService').InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftControl and running == false then
        running = true
	walkingAnimTrack:Stop()
	runningAnimTrack:Play()
        humanoid.WalkSpeed = 40
    elseif input.KeyCode == Enum.KeyCode.LeftControl and running == true then
        running = false
	runningAnimTrack:Stop()
	walkingAnimTrack:Play()
        humanoid.WalkSpeed = 16
    end
end)

1 comment

0

If you don't want to do this, then try stopping and starting the animation track.

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