Hello so I have made many animations in the past but this gun animation is not playing. There are no errors, I have tried debugging by putting “Print(‘bla’)” between the necessary lines. Here is my code and explorer. Everything is connected by welds and joints. Welds for stationary parts, joints for moving parts. Not the whole script is in the code below.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local camera = game.Workspace.CurrentCamera
local aimCF = CFrame.new()
local isAiming = false
local fireAnim = nil
local fireSound = nil
local framework = {
inventory = {
"SPC-A3";
"CZ-75";
};
module = nil;
viewmodel = nil;
currentSlot = 1;
}
function loadSlot(Item)
local viewmodelFolder = game.ReplicatedStorage.ViewModels
local moduleFolder = game.ReplicatedStorage.Modules
for i,v in pairs(camera:GetChildren()) do
if v:IsA("Model") then
v:Destroy()
end
end
if moduleFolder:FindFirstChild(Item) then
framework.module = require(moduleFolder:FindFirstChild(Item))
if viewmodelFolder:FindFirstChild(Item) then
framework.viewmodel = viewmodelFolder:FindFirstChild(Item):Clone()
framework.viewmodel.Parent = camera
fireAnim = Instance.new("Animation")
fireAnim.Parent = framework.viewmodel
fireAnim.Name = "Fire"
fireAnim.AnimationId = framework.module.fireAnim
fireAnim = framework.viewmodel.AnimationController.Animator:LoadAnimation(fireAnim)
end
end
end
loadSlot(framework.inventory[1])
UserInputService.InputBegan:Connect(function(input)
--// SWITCH WEAPONS \\--
if input.KeyCode == Enum.KeyCode.One then
if framework.currentSlot ~= 1 then
loadSlot(framework.inventory[1])
framework.currentSlot = 1
end
end
if input.KeyCode == Enum.KeyCode.Two then
if framework.currentSlot ~= 2 then
loadSlot(framework.inventory[2])
framework.currentSlot = 2
end
end
--// AIM DOWN SIGHTS \\--
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isAiming = true
end
--// SHOOTING \\--
if input.UserInputType == Enum.UserInputType.MouseButton1 then
fireAnim:Play()
character.UpperTorso.Fire:Play()
end
end)
UserInputService.InputEnded:Connect(function(input)
--// AIM DOWN SIGHTS \\--
if input.UserInputType == Enum.UserInputType.MouseButton2 then
isAiming = false
end
--// SHOOTING \\--
if input.UserInputType == Enum.UserInputType.MouseButton1 then
end
end)
function loadSlot(Item)
local viewmodelFolder = game.ReplicatedStorage.ViewModels
local moduleFolder = game.ReplicatedStorage.Modules
for i,v in pairs(camera:GetChildren()) do
if v:IsA("Model") then
v:Destroy()
end
end
print('1')
if moduleFolder:FindFirstChild(Item) then
print("2")
framework.module = require(moduleFolder:FindFirstChild(Item))
if viewmodelFolder:FindFirstChild(Item) then
print("3")
framework.viewmodel = viewmodelFolder:FindFirstChild(Item):Clone()
framework.viewmodel.Parent = camera
fireAnim = Instance.new("Animation")
fireAnim.Parent = framework.viewmodel
fireAnim.Name = "Fire"
fireAnim.AnimationId = framework.module.fireAnim
fireAnim = framework.viewmodel.AnimationController.Animator:LoadAnimation(fireAnim)
end
end
end
make sure to load the animation using the gun animation controller
if you are trying to use another gun animation on this gun it may not work because of the joints name
make sure that the joints are active
note :- joints will not be active if any of the connected parts are anchored*
alright but can you also chaneg the part were you dont directly load the aniamtion to the controller? it still seems liek the main issue, even in the roblox documentation it doesnt say to do that
alright soooo, do you mind if i get access to your game to try and fix it myself? i just cant think of anything else and i would like to do my own debugging! only if you are confortable with it ofcourse
alright so it works just fine, the problem is the animation doesnt even move the gun. make a new one and animate the gun. i created my own for testing and it works. mycomputor isnt good so i cant screen record but yeah. can you try remakign the animation but adding movement to “main”
click add all body
and then select “Main”
publish the aniamtion add chaneg the id to the new one. let me know if it works