Arguments connecting

  1. What do I want to achieve? So I want to make an announcement command, whenever I write !ann (message) a gui would pop up.

  2. What is the issue? The text is only getting the first argument, how do I fix that?

  3. What solutions have you tried so far? I looked around some pages, but couldn’t find the answer

I hope you understand what I’m trying to achieve, it would be awsome if you could help :pray:

Code below V

commands.ann = function(sender, args)
	
	local anre = workspace.Wonder.Essentials.Res.Announce
	local aMessage = args[1]-- needs fixing
	
	
	
	
	
	
	if aMessage then
	anre:FireClient(sender, aMessage)
	end


You’re only sending the first argument of your command, you need to put every argument together into one string and then send it.

1 Like

How do I put every argument together? Do I do string.sub or string.len?

Or simply just get all the text after the “!ann” command, using string.sub. And then create a message with that text.

1 Like

You can iterate through each member of your argument table via a generic for loop and concatenate a new string together.

1 Like

So like, sorry this is new to me

for i,aMessage in pairs(message,sender) do

-- ?

end 

1 Like

Correct, every iteration, concatenate the current message to a string and use that for your announcement.

Yea okay but now I am getting an error under

in pairs(aMessage,sender)

EDIT: okay nvm fixed

My bad, that’s not correct syntax, ipairs only takes one table as an argument.

Oh I see, then what should I use?

The table of arguments, again, in your loop, concatenate each argument to a string which will be used in the final announcement.

It should look something like

for index,arg in ipairs(arguments) do

end

Ohhhh I see and then then

aMessage = arguments

?

If you mean to replace arguments with aMessage then correct.

1 Like

local aMessage = table.concat(args, " ")

1 Like

change aMessage to this:

local aMessage = table.concat(args, " ")

read up on table functions

Yes it works now thank you very much!