Script keeps on printing 'Attempt to call a nil value' whenever I try to call a value from the module

I want to achieve a combo M1 system with 3 m1s, so far, everything but that works.

https://gyazo.com/5fa8768b48dd9dffd70c4ea5f5ef78a5

I’ve looked for atleast 2 hours and I’ve done print checks + removed certain variables + added some and they’ve all printed out the error

Module

local Animations = script:WaitForChild("Animations")
local plr = Animations.Player
local Kat = Animations.Katana

local KeyProvider = game:GetService("KeyframeSequenceProvider")

local Handler = {
	plrAnims = {
		["L"] = plr.R6Slash,
		["LL"] = plr.R6Slash2,
		["LLL"] = plr.R6Slash3	
	},
	
	katanaAnims = {
		["L"] = Kat.R6Slash,
		["LL"] = Kat.R6Slash2,
		["LLL"] = Kat.R6Slash3	
	}
	
}

function Handler.getAnimation(Humanoid, sequence)
	local length = 0
	
	local keyseq = KeyProvider:GetKeyFrameSequenceASync(Handler.plrAnims[sequence].AnimationId)
	local keyFrames = keyseq:GetKeyFrames()
	
	for i=1, #keyFrames do
		local time = keyFrames[i].Time
		if time > length then
			length = time
		end
	end
	
	return Humanoid.Animator:LoadAnimation(Handler.plrAnims[sequence]), length
end


return Handler

Server script

local rp = game:GetService("ReplicatedStorage")
local sword2 = rp:WaitForChild("SwordHandler")

local handler = require(script.Handle)

sword2.OnServerEvent:Connect(function(player, sequence)
	local Character = player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	local HRP = Character:WaitForChild("HumanoidRootPart")
	
	local Katana = Character:FindFirstChild("Katana")
	if Katana then
		print("Found2")
		print(sequence)
		local plrAnim, length = handler.GetAnimation(Humanoid, sequence)
		print(length)
		plrAnim:Play()
		
		task.delay(length,function()
			sword2:FireClient(player)
		end)
	end
end)

Local script

print("TEST")

local rp = game:GetService("ReplicatedStorage")
local sword = rp:WaitForChild("Sword")
local sword2 = rp:WaitForChild("SwordHandler")

print("TEST2")

local uis = game:GetService("UserInputService")
local isEquipped =  false
local debounce = false
local cds = 1
local Player = game.Players.LocalPlayer

print("TEST3")

local Char = game.Workspace:WaitForChild(Player.Name)
local Humanoid = Char:WaitForChild("Humanoid")

local sequence = "L"
local curr = 0
local prev = 0

print("Test4")


uis.InputBegan:Connect(function(input, isTyping)
	
	local Idle = Humanoid:LoadAnimation(script:WaitForChild("Idle", 100))
	local unsheatheanim = Humanoid:LoadAnimation(script.Unsheathe)
	local sheatheanim = Humanoid:LoadAnimation(script.Sheathe)
	if not isTyping then
		if input.KeyCode == Enum.KeyCode.E then
			if not isEquipped and not debounce then
				isEquipped = true
				sword:FireServer(isEquipped)
				unsheatheanim:Play()
				task.wait(0.917)
				Idle:Play()
			elseif isEquipped and not debounce then
				isEquipped = false
				debounce = true
				Idle:Stop()
				sheatheanim:Play()
				wait(1.65)
				sword:FireServer(isEquipped)
			end
		elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
			if isEquipped and not debounce then
				debounce = true

				curr = os.clock()
				local pt = curr - prev 
				if pt < 1 then
					sequence ..= "L"
					if string.len(sequence)>3 then
						sequence = "L"
					end
				else
					sequence = "L"
				end
				sword2:FireServer(sequence)
			end
		end
	end
end)

sword.OnClientEvent:Connect(function()
	wait(cds)
	debounce = false
end)

sword2.OnClientEvent:Connect(function()
	prev = curr
	debounce = false
end)

Hi 608b,

function Handler.getAnimation(Humanoid, sequence)

In your module, you define a function of the name “getAnimation”

local plrAnim, length = handler.GetAnimation(Humanoid, sequence)

In your server script, you call a function by the name of “GetAnimation”

There is a difference in capitalization between the two.

Hope it helps!

1 Like

Let me try that out, thanks for the reply.

Yup, that solved it, thanks for the quick reply!