Attempted to Index Nil with Statuslist

THE TITLE IS THE ERROR FEEDBACK

*** MODULE SCRIPT ***
I know It’s long but bear with me now

local characterStatusManager = {}
laststun = {};
aircombo = {};
aircombocheck = {};
characterStatusManager.currentair = {};
characterStatusManager.__index = characterStatusManager
PS = game:GetService("Players")


local VFX = require(game.ReplicatedStorage.FXModule)
local framework = require(script.Parent)

Characters = {}

function characterStatusManager.new(character)
	local self = setmetatable({}, characterStatusManager)
	self.Character = character
	return self
end

function characterStatusManager:AddCharacter(character)
	local player = PS:GetPlayerFromCharacter(character)
	if player ~= nil then
	local playerStatus = framework.new(character)
	Characters[player.UserId] = playerStatus
	laststun[player.UserId] = os.clock()
	aircombo[player.UserId] = os.clock()
	else
	local playerStatus = framework.new(character)
	Characters[character] = playerStatus
	laststun[character] = os.clock()
	aircombo[character] = os.clock()
	end
end

function characterStatusManager:RemoveCharacter(character)
	local player = PS:GetPlayerFromCharacter(character)
	if player ~= nil then
		Characters[player.UserId] = nil
	else
		Characters[character] = nil
	end
end

function characterStatusManager:RetriveStatus(character)
	local player = PS:GetPlayerFromCharacter(character)
	if player ~= nil then
		return Characters[player.UserId].StatusList
	else
		return Characters[character].StatusList
	end
end

function characterStatusManager:StatusCheck(character, hitcharacter: Model, canblock: boolean, canparry: boolean, ragdoll: boolean, ignorespecial: boolean)
	local FStatus = characterStatusManager:RetriveStatus(character)
	local Status = characterStatusManager:RetriveStatus(hitcharacter)
	if Status.Blocking and canblock then
		VFX.CreateSound('rbxassetid://18912884921', 0.2, 1, hitcharacter)
		VFX.Highlight(hitcharacter, Color3.new(0, 0, 1), 0.4)
		return "blocked"
	elseif Status.Blocking and not canblock then
		return	"true"
	end
	if Status.Parrying and canparry then
		VFX.CreateSound('rbxassetid://8132494511', 0.2, 1, character)
		characterStatusManager:Stun(character, 2)
		VFX.Highlight(hitcharacter, Color3.new(1, 1, 0), 0.4)
		return "parried"
	elseif Status.Parrying and not canparry then
		return "true"
	end
	if Status.Misc and ragdoll then
		return "true"
	elseif Status.Misc and not ragdoll then
		VFX.Highlight(hitcharacter, Color3.new(0.4, 0.4, 0.4), 0.4)
		return "ragdolled"
	end
	if Status.IFrames then
		return "IFrames"
	end
	if Status.SpecialAction ~= "" and not ignorespecial then
		require(game.ServerScriptService.CombatFramework.SpecialActions).Search(Status.SpecialAction, hitcharacter, character)
		return "special"
	elseif Status.SpecialAction ~= "" and ignorespecial then
		return "true"
	end
	if Status.SpecialAction == "" and not Status.Blocking and not Status.IFrames and not Status.Misc and not Status.Parrying then
		return "true"
	end
end

function characterStatusManager:Stun(character: Model, Time)
	local current_stun = os.clock()
	local plr = PS:GetPlayerFromCharacter(character)
	local StatusList
	if plr ~= nil then
	StatusList = Characters[plr.UserId].StatusList
	laststun[plr.UserId] = current_stun
	else
	StatusList = Characters[character].StatusList
	laststun[character] = current_stun
	end
	local Humanoid = character:FindFirstChildOfClass("Humanoid")
	local Animator = Humanoid:FindFirstChildOfClass("Animator")
	for _,anim in ipairs(Animator:GetPlayingAnimationTracks()) do
		anim:Stop()
	end
	Humanoid.WalkSpeed = 0
	print("stunned")
	if StatusList.Blocking or StatusList.Parrying then
	StatusList.Blocking = false
	StatusList.Parrying = false	
	end
	StatusList.Stunned = true
	task.delay(Time, function()
	if plr == nil then
		if laststun[character] == current_stun then
			Humanoid.WalkSpeed = 16
			print("unstunned")
			StatusList.Stunned = false
			end
	elseif plr ~= nil then
		if laststun[plr.UserId] == current_stun then
				Humanoid.WalkSpeed = 16
				print("unstunned")
				StatusList.Stunned = false
		end
		end
	end)
end



function characterStatusManager:ReturnCombatData(character)
	local player = PS:GetPlayerFromCharacter(character)
	if player ~= nil then
		return Characters[player.UserId].CombatData
	else
		return Characters[character].CombatData
	end
end
return characterStatusManager

I have NEVER had this issue before…
If more Information is required please LMK

what is the error and what line it occur? It would help us pin point the problem easily

Indexing nil with Statuslist means you are trying to find the child of a nil object.

local Dictionary = nil
print(Dictionary["Statuslist"]) --Attempt to index nil with Statuslist
print(Dictionary.Statuslist) --This is the same

Since I don’t know what line this error occurs on (please tell next time), this could happen anywhere .Statuslist is.
That being, in order of apperance:

return Characters[player.UserId].StatusList
return Characters[character].StatusList
StatusList = Characters[plr.UserId].StatusList
StatusList = Characters[character].StatusList

Two things can be happening, Either player.UserId or character are nil. or the Characters table does not have that index. I would recommend figuring out that first.

Looking at characterStatusManager:RetriveStatus and characterStatusManager:Stun it seems weird that if plr is nil, then it would try to use character as the index. I would think that character would also be nil if you cant use it to find the player.

Please figure out if plr.UserId or character is nil or if Characters does not have the index. Good luck!

Sorry the reply was late, the script in which the error is occuring im guessing is here…

RFunc.OnServerInvoke = function(plr, arg)
	print(plr)
	if arg == "Status" then
	return StatusMod:RetriveStatus(plr.Character)
	elseif arg == "Cooldown" then
	return NormalMoves[StatusMod:ReturnCombatData(plr.Character).Weapon].Cooldown
	elseif arg == "CombatData" then
	return StatusMod:ReturnCombatData(plr.Character)
	end
end
local M1 = UIS.InputBegan:Connect(function(input, gpe)
	if not gpe and can_m1 then
		local playerStatus = RFunc:InvokeServer("Status")
		local weaponCooldown = RFunc:InvokeServer("Cooldown")
		if input.UserInputType == Enum.UserInputType.MouseButton1 and not playerStatus.Stunned and not playerStatus.Cutscene and not playerStatus.InAction and not playerStatus.Blocking then
			while UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) and can_m1 do
			playerStatus = RFunc:InvokeServer()
				if playerStatus.Stunned or playerStatus.Cutscene or playerStatus.InAction or playerStatus.Blocking then return end

The top part is the server script, bottom is the clientside. It fires a remote function which returns something based on the arg, Everytime I get a error its from the original module AND the client.

oh wait bruh the issue was i didn’t set up the players in the first place…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.