When I run my script. I don’t got a error or anything, just nothing happens. What I’m trying to do is when I run “:m blalbalalal” the UI tweens showing the text and all that. But when I type it out nothing happens with no print of an error. Please help me.
Server:
-- Heading --
{
Names = {'h'},
Level = ModLvl,
Function = function(Chatted,Arguements,Message)
-- Check --
if Message then
local FilteredMsg = FilterMsg(Message,Chatted)
AdminFolder.CrossClient:FireAllClients('h',{Chatted,FilteredMsg})
end
end,
},
-- Message --
{
Names = {'m'},
Level = AdminLvl,
Function = function(Chatted,Arguements,Message)
-- Check --
if Message then
local FilteredMsg = FilterMsg(Message,Chatted)
AdminFolder.CrossClient:FireAllClients('m',{Chatted,FilteredMsg})
end
end,
},
Client:
--- [IMPORTANT] --
local function ClientEvent(Cmd,...)
local Arguements = {...}
-- Check --
if Cmd == 'h' then
local Plr = Arguements[1]
local Msg = Arguements[2]
HeadMessage(Plr,Msg)
elseif Cmd == 'm' then
local Plr = Arguements[1]
local Msg = Arguements[2]
BodyMessage(Plr,Msg)
end
end
----
-- Finalize --
AdminFolder.CrossClient.OnClientEvent:Connect(ClientEvent)
----
You see, in your Server-Client signal, your 2nd argument is a table containing Chatted and FilteredMsg.
When you’re receiving this signal on the client, you’re inserting the original table containing the arguments to another table:
local Arguements = {...}
What you’re doing here is basically inserting the original table as an element inside of another table on the client:
local Arguements = { {Chatted,FilteredMsg} }
Now when you try accessing Arguements[2] of this table, it returns nil considering it is only holding one element, which itself is a table containing your expected arguments.
Solutions:
In order to simply fix this, you can take out your arguments holder outside of the table in your ClentEvent() function:
local Arguements = ...
Another way you could fix this is by changing the way you access the expected values from the “nested” table that you have:
if Cmd == 'm' then
local Plr = Arguements[1][1]
local Msg = Arguements[1][2]
BodyMessage(Plr,Msg)
end
Give it a shot and see if you manage to achieve the intended behavior. Please feel free to report back on any issues or anything I may have missed or misunderstood.
I don’t believe I’m noticing any immediate issues with the way you’ve implemented those changes. This leads me to believe that the issue may now be inside your BodyMessage() function, presuming that’s what’s handling the tweening and appearing of the GUI. If you’re able to post your BodyMessage() function, that may help point us in the right direction.
Additionally, it always helps to do some basic debugging, for example printing Plr or Msg after they’ve been assigned the correct value to see if those variables contain what you’re expecting them to.
As I see here, you’re trying to access the Name property of the supposed Plr Instance, which I believe may be your issue here (or one of).
In your client signal here, :FireAllClients('m',{Chatted,FilteredMsg}), may I ask what exactly are the 2 elements of the table, Chatted and FilteredMsg? How are you getting them?
As I mentioned here, it is always helpful to debug your code such as by simply printing certain checkpoints such as Plr.Name or Msg to assure the correct arguments are being parsed and processed. It is also important to look out for any potential errors that your code may be outputting. Have you checked your console for any errors that your LocalScript may be outputting?
You should try changing your client script to this:
--- [IMPORTANT] --
local function ClientEvent(Cmd, tbl)
local Arguements = tbl
-- Check --
if Cmd == 'h' then
local Plr = Arguements[1]
local Msg = Arguements[2]
HeadMessage(Plr,Msg)
elseif Cmd == 'm' then
local Plr = Arguements[1]
local Msg = Arguements[2]
BodyMessage(Plr,Msg)
end
end
----
-- Finalize --
AdminFolder.CrossClient.OnClientEvent:Connect(ClientEvent)
----
--- [IMPORTANT] --
local function ClientEvent(Cmd, Arguements)
local Plr, Msg = unpack(Arguements)
-- Check --
if Cmd == 'h' then
HeadMessage(Plr,Msg)
elseif Cmd == 'm' then
BodyMessage(Plr,Msg)
end
end
----
-- Finalize --
AdminFolder.CrossClient.OnClientEvent:Connect(ClientEvent)
----