So i've tested this animation and it works completely fine in studio "play" mode, but when I head over to my server, it does not work.

function mine()
	if CanMine.Value == 1 then
		if BlockSelected.Value == 1 then
			local animation = Instance.new("Animation")
			animation.AnimationId = "http://www.roblox.com/Asset?ID=338675979"
			local Humanoid = script.Parent.Parent.Humanoid
			local animation = Humanoid:LoadAnimation(animation)
			Humanoid.WalkSpeed = 5
			animation:Play()
			wait(2)
			Humanoid.WalkSpeed = 16
end
end
end

I've tried removing the local's and it doesn't have effect, does anyone see the issue?

EDIT: I ran a few tests, and it seems to me that when I remove the if statements the animation will run, but when I have the if statements in it will only run in studio not on a server/studio test server.