I have a few animations are supposed to play as you equip, idle, shoot, but for some reason, they become NIL after I equip the gun or wait a second too long.
(I have two weapons, my “Laser Musket” and “Hand Cannon”, my Laser Musket has NO issues and its PERFECT, but my HAND CANNON is what is breaking, despite both sharing basically the same code.)
A video to see what I mean.
I dont have an inkling of what this could be caused by, I’ve tried every solution–and it’d be helpful to know if anyone has had similar issues, if you have any inquiries please LMK…
(Handcannon Code so you can see that I am not loading the animation and playing it at the same time)
Animations = AnimationTable
Configuration = Config
HumanoidRootPart = RootPart
Humanoid = Soul
coroutine.wrap(function()
while task.wait(0.1) do
for _, element in ipairs(AnimationTable) do
warn(element)
end
end
end)()
print(Tool, AnimationTable, Config, RootPart, Soul)
Weapon.Equipped:Connect(function()
print("I SHOULD FIRE...?")
Animations["EquipH"]:Play()
task.wait(0.15)
Animations["IdleH"]:Play()
Humanoid.AutoRotate = false
Connection = RunService.RenderStepped:Connect(function()
if Humanoid.Health <= 0 then return end
local MousePosition = Mouse.Hit.Position
local LookToV3 = Vector3.new(MousePosition.X, HumanoidRootPart.CFrame.Y, MousePosition.Z)
HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.CFrame.Position, LookToV3)
end)
end)
The script provided is quite vague as it only shows a portion of your script… How do you get your module (did you use require)? What is animation table and config? How are they defined locally?
The module works fine, as I’ve said I am reusing a previous weapon module, (Laser Musket) to run my functions–dont really see the need for the entire script since the core issue lies with the animation, not the code–My animator table is a returned result from another module that I wrote that loads all the animations my client would need, which ill attach below, config does not matter.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Animations = ReplicatedStorage:WaitForChild("Animations")
local Tools = Animations:WaitForChild("Tools")
local AnimationLoader = {}
local LoadedAnimations = {}
local Group = {}
function AnimationLoader:LoadWeaponAnimations(Weapon, Humanoid)
local Animator = Humanoid:WaitForChild("Animator")
local AnimationIDsToLoad = Tools[Weapon]:GetChildren()
table.clear(Group)
for _, Animation in pairs(AnimationIDsToLoad) do
--if table.find(LoadedAnimations, Animation) then
-- print("Already Loaded")
-- Group[Animation.Name] = Animation
--end
local AnimationTrack = Animator:LoadAnimation(Animation)
Group[Animation.Name] = AnimationTrack
LoadedAnimations[Animation.Name] = AnimationTrack
end
return Group
end
return AnimationLoader
The animations are found and, as evidently shown in the video, will play and work–the issue is that they become NIL for reasons that have yet to be found.
No line errors out except for the lines that call the animation to play or stop, because the script reads them as nil…
I do ask to not speak on the issue if you cant atleast infer what the error details.
The issue does not SIT with the HANDLER(MODULE) of the GUN, as proven by the Laser Musket (A SEPERATE GUN WITH THE EXACT SAME CODE THAT STILL WORKS), The Point of the post is to help identify why animations are becoming nil (an issue also NOT present with the Laser Musket)
I’ve rechecked both your code several times over… I don’t really see a problem with both of them… Since you’ve mentioned that the animations play anyway, even though they return nil…
I think the problem is with the animation or animationtrack itself… Although I’m not sure exactly what the problem is. I’m quite confused too since I’m not able to outright test your script. Sorry if I’m not able to help.