This is mainly just how I am loaded animations
I have been working on an fps system for a while now and im making a better version, and I am roughly following this tutorial Writing an FPS framework (2020).
But I am stuck on loading animations, as they keep coming back as nil. I am sharing my main script for this and along with that I will send my rblx file if needed. fpsplace.rbxl (727.5 KB)
local GunController = {}
GunMT = { __index = GunController }
local ReplicatedStorage = game:GetService("ReplicatedStorage")
function GunController:New(Viewmodel, CurrentGun)
local self = setmetatable({}, GunMT)
self.Viewmodel = Viewmodel
self.Gun = ReplicatedStorage.Storage.Guns:WaitForChild(CurrentGun)
self.Gun.Parent = self.Viewmodel
self.AnimationController = self.Viewmodel.AnimationController
self.Animations = {
Equip = self.AnimationController:LoadAnimation(self.Gun.Animations.Equip),
Idle = self.AnimationController:LoadAnimation(self.Gun.Animations.Idle)
}
return self
end
function GunController:Equip()
self.Animations.Equip:Play()
self.Animations.Idle:Play()
self.Equipped = true
end
function GunController:Update(dt)
if self.Equipped then
self.Viewmodel.PrimaryPart.CFrame = workspace.CurrentCamera.CFrame
end
end
return GunController
ReplicatedStorage.Framework.GunController:23: attempt to index nil with ‘Equip’ - Client - GunController:23
Thanks for taking the time to read my post and help,