Admin logs erroring nil

Hey, I have an admin logs system, yet when I want it to print out the command the player has run it gives nil and errors.

Error:

Players.max123lover2.PlayerGui.AdminGui.ChatLog.chatlog_handler:138: attempt to concatenate string with nil  -  Client - chatlog_handler:138

Local Script:

event.OnClientEvent:Connect(function(command, chatType)
	if chatType == "ADMINLOG" then
		print(command)
		
		makeResizable(AdminFrame)
		makeDraggable(AdminFrame)

		local templateClone = template:Clone()
		templateClone.Parent = AdminScrollingFrame
		templateClone.Text =  player.Name..": ".. command
	end
end)

ServerScript:


local rs = game:GetService("ReplicatedStorage")
local sss = game:GetService("ServerScriptService")
local event = rs.Events.chatEvent

local commands = sss.AdminSystem.Commands

local prefix = "/"

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if string.sub(msg, 1, 1) == prefix then
			local command = commands:FindFirstChild(string.split(string.sub(msg, 2, #msg), " ")[1])
			print(command)
			event:FireClient(player, command, "ADMINLOG")
		end
	end)
end)

Help is appreciated.

1 Like

The error is occuring because

commands:FindFirstChild(string.split(string.sub(msg, 2, #msg), " ")[1])

is returning nil.

Can you please check that the item for the command exists? It will help if you get the string.split()[1] part outputted as well, to see what it is looking for

When you print the command it does print the command you have ran.

1 Like

I just noticed the issue.

All of the commands are stored in ServerScriptService, an area which is unaccessible to the client, hence it does not see the command.

You’ll either need to find some other way to transfer the data in the command, or move the commands thing to replicated storage, in order to get it to work correctly

2 Likes

Even with a remote event? Cause it is used.

1 Like

Does the command print nil on local?

1 Like

The remote event sends the object itself, but as the object is contained in an area the client can’t see, the remote event is unable to properly send the data.

2 Likes

Yes, it does print nil on local.

1 Like

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