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

Why does this script not work after i wait a little after the 2nd animation plays?

If i keep pressing E, then it work's perfectly. But if i press E twice and wait a little, it won't play the other animation, or just prints('2'), and nothing after. Any ideas on why this is happening?

wait(game.Lighting.TimeToLoad.Value)

local UIS = game:GetService("UserInputService")
chain = 0

--//Combat Animation
local combat1 = Instance.new("Animation")
combat1.AnimationId = "http://www.roblox.com/Asset?ID=1093151226"
--
local combat2 = Instance.new("Animation")
combat2.AnimationId = "http://www.roblox.com/Asset?ID=1093152736"
--
local combat3 = Instance.new("Animation")
combat3.AnimationId = "http://www.roblox.com/Asset?ID=1093155314"
--
local combat4 = Instance.new("Animation")
combat4.AnimationId = "http://www.roblox.com/Asset?ID=1093156822"
--
local combat5 = Instance.new("Animation")
combat5.AnimationId = "http://www.roblox.com/Asset?ID=1093157747"
--
local combat6 = Instance.new("Animation")
combat6.AnimationId = "http://www.roblox.com/Asset?ID=1093158550"

UIS.InputBegan:Connect(function(Input, gameProcessedEvent)
	local KeyCode = Input.KeyCode
	if gameProcessedEvent == false then
		
	if KeyCode == Enum.KeyCode.E and chain == 0 then
		chain = 1
		print('1')
		local animTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(combat1)
animTrack:Play()
workspace.CurrentCamera.Sounds.P1:Play()
wait(.5)
chain = 2
	else
	if KeyCode == Enum.KeyCode.E and chain == 2 then
		chain = 3
		print('2')
		local animTrack2 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(combat2)
animTrack2:Play()
workspace.CurrentCamera.Sounds.P1:Play()
wait(.5)
chain = 4
	else
	if KeyCode == Enum.KeyCode.E and chain == 3 then
		chain = 4
		print('3')
		local animTrack3 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(combat3)
animTrack3:Play()
workspace.CurrentCamera.Sounds.P1:Play()
wait(.5)
chain = 5
	else
	if KeyCode == Enum.KeyCode.E and chain == 5 then
		chain = 6
		print('4')
		local animTrack4 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(combat4)
animTrack4:Play()
workspace.CurrentCamera.Sounds.P1:Play()
wait(.5)
chain = 7
	else
	if KeyCode == Enum.KeyCode.E and chain == 7 then
		chain = 8
		print('5')
		local animTrack5 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(combat5)
animTrack5:Play()
workspace.CurrentCamera.Sounds.P1:Play()
wait(.5)
chain = 9
	else
	if KeyCode == Enum.KeyCode.E and chain == 9 then
		chain = 10
		print('6')
		local animTrack6 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(combat6)
animTrack6:Play()
workspace.CurrentCamera.Sounds.P1:Play()
wait(.5)
chain = 0
		print('reset')
	end
	end
	end
	end
	end
	end
	end
end)

1 answer

✓ Accepted answer

Because of your comments

--
local combat2 = Instance.new("Animation")
combat2.AnimationId = "http://www.roblox.com/Asset?ID=1093152736"

As you can see, your comment is preventing the creation of an Animation via Instance.new(). Remove the comments and it should work. This happens on all your animations apart from the first, explaining why only it works.

1 comment

0

Ohh, thank's. I didn't even see that.

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