Animations not playing despite it saying it does

Heya Everyone!!

I’m working on a free-for-all, first person shooter. I’m trying to make the animations play but the issue is that for some reason, the animations are not playing despite it saying it is whenever I put self.WeaponSettings.IdleTrack.IsPlaying == true.

WeaponSettings

local WeaponSettings = {
	Damage = 15,
	Firerate = 0.5,
	AmmoLoaded = 12, --//AmmoLoaded means how many ammo the gun has before needing to reload.
	AmmoCarried = 200, --//AmmoCarried means how much ammo the gun has before needing to get an ammo box.
}

WeaponSettings.IdleAnim = script:WaitForChild("Idle") --Trying to find a better place to put the animations. Putting here temporarily.

return WeaponSettings

WEAPON_HANDLER

--[[SERVICES]]--
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--[[FOLDERS]]--
local WEAPONS = ReplicatedStorage:WaitForChild("WEAPONS")
local EVENTS = ReplicatedStorage:WaitForChild("EVENTS")

--[[MODULE]]--
local WEAPON_HANDLER = {}
WEAPON_HANDLER.__index = WEAPON_HANDLER

function WEAPON_HANDLER.New(CharacterModel) --//This is really just getting the player model and humanoid
	local self = setmetatable({}, WEAPON_HANDLER)
	
	self.Character = CharacterModel
	self.Humanoid = self.Character:FindFirstChildWhichIsA("Humanoid")
	self.Animator = self.Humanoid:FindFirstChildWhichIsA("Animator")
	self.Motor6D = self.Character["Right Arm"]:FindFirstChild("HandleGrip")
	
	return self
end

function WEAPON_HANDLER:EquipWeapon(RequestedWeapon)
	self.Weapon = WEAPONS:FindFirstChild(RequestedWeapon)
	self.WeaponSettings = require(self.Weapon:FindFirstChild("WeaponSettings"))
	
	--//Welding the weapon model to the player and showing it in the server
	self.Motor6D.Part1 = self.Weapon.Handle
	self.Weapon.Parent = self.Character
	
	--//List of animations and playing them
	self.WeaponSettings.IdleTrack = self.Animator:LoadAnimation(self.WeaponSettings.IdleAnim)
	self.WeaponSettings.IdleTrack:Play()
	
	if self.WeaponSettings.IdleTrack.IsPlaying == true then
		print("Playing")
	end
	
	--//After we're done positioning the weapon to the player, replicate it to the server
	EVENTS.REPLICATE_WEAPON_TO_SERVER:FireServer(RequestedWeapon)
end

function WEAPON_HANDLER:FireWeapon()
	--//TBA
end

function WEAPON_HANDLER:ReloadWeapon()
	--//TBA
end

return WEAPON_HANDLER

I’ll also provide a local script which handles all the weapons.

Gonna bump this since I really need an answer

If this is in a regular Server Script, you should try firing a RemoteEvent to a LocalScript instead. Some things, like animations, replicate from the client to the server instead of the other way around. In that LocalScript, make sure to use Animator:LoadAnimation() when initializing your animation variables. The animations can be parented to that LocalScript. You can choose to make an Animations folder, or just parent them directly.

Because this is a ModuleScript, you are allowed to use both FireServer and FireClient, but make sure to call these functions from the right type of script.

It’s actually a module script that’s being used in a local script (which I’ll provide from below)

WEAPON_CONTROLLER

--[[SERVICES]]--
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")

--[[LOCAL PLAYER AND CHARACTER MODEL]]--
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()

--[[MODULE]]--
local WEAPON_HANDLER = require(game:GetService("ReplicatedStorage").CLIENT_MODULES.WEAPON_HANDLER)

--[[CONTROLS]]--
local PlayerWeaponHandler = WEAPON_HANDLER.New(Character)
local DefaultWeaponInventory = {
	"Pistol" --//Will be switched to the Linked Sword later.
}

local function EQUIP()
	PlayerWeaponHandler:EquipWeapon("Pistol")
end

local function FIRE()
	--//TBA
end

local function RELOAD()
	--//TBA
end

EQUIP()
ContextActionService:BindAction("FireWeapon", FIRE, true, Enum.UserInputType.MouseButton1)
ContextActionService:BindAction("ReloadWeapon", RELOAD, true, Enum.KeyCode.R)

--[[VIEWMODEL]]--
--//This isn't really actually a viewmodel.
--//This is actually just setting the arms visible so I don't need to worry about making an actual viewmodel.
game:GetService("RunService").RenderStepped:Connect(function()
	for _, Part in pairs(Character:GetChildren()) do
		if Part:IsA("Part") and (Part.Name == "Right Arm" or Part.Name == "Left Arm") then
			Part.LocalTransparencyModifier = 0
		end
	end
end)

Is the animation priority set to Core or Idle? Because roblox will override those with walking and idle animations. Instead set it to Action or Action1 etc.

Animation priority is set to Action and Action2 respectively.

  • Maybe it’s to do with the fact that self.WeaponSettings.IdleTrack isn’t a part of your original WeaponSettings? Instead maybe define a self.IdleTrack in your .New(),
  • Or it could be that you uploaded the animation yourself but the game is published by a group? If so the animation has to be owned by the group I think
  • Maybe try using :WaitForChild("Animator") instead of :FindFirstChildWhichIsA("Animator"). Could be that the animator hasn’t loaded yet?

Did you ever figure this out? I’ve found myself facing a similar issue.