Functions arguments are nil

So I am making custom chat system and I started first making my own custom ChatMakeSystemMessage this is the function that needs to be called when making the message

function Functions:ChatMakeSystemMessage(Text,Color,Font,Size)
	print(Text)
	print(Color)
	print(Font)
	print(Size)
	local Success,Erorr = self:Create("TextLabel",{
		BackgroundTransparency = 1,
		TextColor3 = Color,
		Font = Font,
		TextSize = Size,
		Text = Text,
		Name = self.Messages + 1,
		Parent = ChatMessageArea
	})
	
	if not (Success) then
		print(Erorr)
		return
	end
	
	if (Success) then
		table.insert(self.MessageTable,Erorr)
		--self:Organize()
		return
	end
end

Call

ChatInstall:ChatMakeSystemMessage(unpack({
	Text = "{System} Your friend has joined you ",
	Color = Color3.fromRGB(255,255,255),
	Font = Enum.Font.Cartoon,
	Size = Enum.FontSize.Size24
}))

But when I call the functions every argument is printed as nil.

image

image

unpack is for arrays, not dictionaries. Unpacking a dictionary won’t return anything.

2 Likes

Thanks you!
image

1 Like

It did work, but I have to make sure if I am correct.

image

1 Like

Yep, that looks right. If you don’t have any issues with it, you can usually assume it’s fine.

1 Like

Why do you need to call the function like that though?
Why don’t you just do this:

ChatInstall:ChatMakeSystemMessage(
    "{System} Your friend has joined you ",
    Color3.fromRGB(255,255,255),
    Enum.Font.Cartoon,
    16
)

No need to wrap the arguments into a table only to unpack them in the next step.

2 Likes

There is a reason why I am not doing like that because this is Admin commands plus that was an example code.

One more thing. If you are making a custom chat system, remember to use TextService:FilterStringAsync() to filter out bad (or “bad”) words. :smiley:

Chat filtering has already been addressed in a different thread, this is regarding a function intended to send system messages to their custom chat. Text filtering is not required on non-custom input systems (developer-inputted text), however there is an expectation that the words you use are appropriate.