Q the play animation error

I’m trying to play an animation when Q is pressed.

script (line 49 and 50 is where it prints/plays)

local lightbeam
lightbeam = true
local uis = game:GetService("UserInputService")
local equipted
local lightsaberStatus

local player = game.Players.LocalPlayer

local char = player.Character or player.CharacterAdded:Wait()

local h = char:WaitForChild("Humanoid")



script.Parent.Equipped:Connect(function(Mouse)
	equipted = true
	Mouse.Button1Down:Connect(function()
		if lightbeam == true then
			wait(0.3)
			script.Parent.Light.Transparency = 0.07
			lightbeam = false
			script.lightsaber_powerup:Play()
			lightsaberStatus = true
		else
			wait(0.3)
			script.Parent.Light.Transparency = 1
			lightbeam = true
			script.Lightsaber_Close:Play()
			lightsaberStatus = false
		end


	end)
end)

script.Parent.Unequipped:Connect(function()
	equipted = false
end)


local SwingAnim = script.swing

local AnimationTrack = h:LoadAnimation(SwingAnim)


uis.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Q then
		if equipted == true then
			if lightsaberStatus == true then
				print("why")
				AnimationTrack:Play()
				
				local bean = math.random(1,4)
				if bean == 1 then
					script["Lightsaber Swing 1"]:Play()
				end
				if bean == 2 then
					script["Lightsaber Swing 2"]:Play()
				end
				if bean == 3 then
					script["Lightsaber Swing 3"]:Play()
				end
				if bean == 4 then
					script["Lightsaber Swing 4"]:Play()
				end	
	end	
		end
		
		end
		

end)

I have no clue on what is going wrong/not working

If the game is from a group

Try reuploading the animation, But set the “Creator” to your group name

the game and the animation are both made by me

Maybe try turning off team create in your game

Team create isn’t on also, if I have a welding script would that effect anything?

Doesn’t matter, needs to be put under a group if the game is made by a group.

the game is not under a group, its just under me

I dont believe so, my animations with welds work fine.

What is your animation priority set at?
try doing

print("why")
AnimationTrack.Priority = Enum.AnimationPriority.Action
AnimationTrack:Play()
1 Like