Play is not a valid member of Animation "Animation"

I’m writing a simple reload script. Here’s the script:

local UserInputService = game:GetService("UserInputService")
local Amunition = 20
local Test = Instance.new("Animation")
Test.AnimationId = "rbxassetid://6587068338"
local Test = Animator:LoadAnimation(Test)
Test.Priority = Enum.AnimationPriority.Action
Test.Looped = false

UserInputService.InputBegan:Connect(function(input, gameProccesedEvent)
	if input.KeyCode == Enum.KeyCode.R then
		if Amunition < 20 then
			Amunition = 20
			Test:Play()
		end
	end
end)
local function Shoot(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		Amunition -= 1
	end
end

UserInputService.InputBegan:Connect(Shoot)

But the script has been giving me this error:

Play is not a valid member of Animation "Animation"

Does anyone know how to solve this issue?

1 Like
local Test = Instance.new("Animation")
local Test = Animator:LoadAnimation(Test)

You have two variables named “Test”, the script probably can’t tell the difference and is using the wrong one.

1 Like