iiLok_i
(ItzLokiHere)
October 6, 2020, 5:06pm
#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.
What is the issue? The text is only getting the first argument, how do I fix that?
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
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
zeplar_exe
(zeplar_exe)
October 6, 2020, 5:24pm
#2
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
iiLok_i
(ItzLokiHere)
October 6, 2020, 5:27pm
#3
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
zeplar_exe
(zeplar_exe)
October 6, 2020, 5:28pm
#5
You can iterate through each member of your argument table via a generic for loop and concatenate a new string together.
1 Like
iiLok_i
(ItzLokiHere)
October 6, 2020, 5:30pm
#6
So like, sorry this is new to me
for i,aMessage in pairs(message,sender) do
-- ?
end
1 Like
zeplar_exe
(zeplar_exe)
October 6, 2020, 5:31pm
#7
Correct, every iteration, concatenate the current message to a string and use that for your announcement.
iiLok_i
(ItzLokiHere)
October 6, 2020, 5:32pm
#8
Yea okay but now I am getting an error under
in pairs(aMessage,sender)
EDIT: okay nvm fixed
zeplar_exe
(zeplar_exe)
October 6, 2020, 5:33pm
#9
My bad, that’s not correct syntax, ipairs
only takes one table as an argument.
iiLok_i
(ItzLokiHere)
October 6, 2020, 5:36pm
#10
Oh I see, then what should I use?
zeplar_exe
(zeplar_exe)
October 6, 2020, 5:37pm
#11
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
iiLok_i
(ItzLokiHere)
October 6, 2020, 5:40pm
#12
Ohhhh I see and then then
aMessage = arguments
?
zeplar_exe
(zeplar_exe)
October 6, 2020, 5:41pm
#13
If you mean to replace arguments
with aMessage
then correct.
1 Like
blokav
(blokav)
October 6, 2020, 5:42pm
#14
local aMessage = table.concat(args, " ")
1 Like
Styre_x
(Styrex)
October 6, 2020, 5:43pm
#15
change aMessage to this:
local aMessage = table.concat(args, " ")
read up on table functions
iiLok_i
(ItzLokiHere)
October 6, 2020, 5:44pm
#16
Yes it works now thank you very much!