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

Why wont this animation play?

This script should be playing an animation based on whether Stance.Value = right or left. It plays the cooresponding animation for 'left' but not for right. It's strange. Any help is appreciated.

	--Player Values
	local move_left = false
	local move_right = false
	local already_ran = false
	local grounded = false
	local idleAnimation = Instance.new("Animation")
	idleAnimation.AnimationId = "rbxassetid://317651678"
	local runningAnimation = Instance.new("Animation")
	runningAnimation.AnimationId = "rbxassetid://319211805"
	local R2 = Instance.new("Animation")
	R2.AnimationId = "rbxassetid://319228239"
	--local I2 = Instance.new("Animation")
	--I2.AnimationId = "rbxassetid://319228239"
	
		
	function playAnimation(parent)
		local AnimTrack = player.Character.Humanoid:LoadAnimation(parent)
		AnimTrack:Stop()
		wait(.1)
		AnimTrack:Play()
	end
	
	function onGround(speed)
		if grounded == false then
			grounded = true
		end
		if speed > 1 and player.PlayerGui.SwordPlaySystem.Stance.Value == ("Left") then -- This one works
			if already_ran == false then
				already_ran = true
				playAnimation(runningAnimation)
				
				elseif  speed > 1 and player.PlayerGui.SwordPlaySystem.Stance.Value == ("Right") -- this one doesn't 
		then
					if already_ran == false then
						already_ran = true
						playAnimation(R2)
				end	
			end 
		else
			already_ran = false
			playAnimation(idleAnimation)
		end
	end
	
end

1 comment

0

what type of scirpt is it in

1 answer

✓ Accepted answer

Ah, just a small mistake. The elseifcode is running under the wrong if statement. Simply fix this by adding an end before the elseif of Stance.Value == ("Right")

2 comments

1

He's right.

0

Wooh! Thanks alot c:

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