So I'm working on a message command for my custom commands and I'm having trouble with it.
I have an invisible GUI in the StarterGui that is basically a template for the message, but I need to edit all the instances of it in all the PlayerGui folders, and right now I'm stuck using a bunch of for loops inside of each other but that doesn't work because I need the variable from the first function and it just became a whole mess.
cmds.m = function(sender, args)
local who = sender.Name
if who then
local ScreenGui = game.StarterGui.messageGui
local Frame = ScreenGui.theFrame
local message = Frame.lemessage
local sendername = Frame.sender
for i,v in pairs(args) do
if v == args[1] then
for i,v in pairs(game.Players:GetDescendants()) do
if v.Name == "lemessage" then
v.Text = args -- I need this to get the information from the first for loop (same with all the other lines that say "args")
print("args = ".. args)
end
end
else
for i,v in pairs(game.Players:GetDescendants()) do
if v.Name == "lemessage" then
v.Text = v.Text .." ".. args
end
end
end
print("The message is: "..message.Text)
end
sendername.Text = who
for i,v in pairs(game.Players:GetDescendants()) do
if v.Name == "messageGui" then
for i = 1, 5 do
v.theFrame.BackgroundTransparency = v.theFrame.BackgroundTransparency-0.05
end
elseif v.Name == "theFrame" and v.BackgroundTransparency <= 0.75 then
for i,v in pairs(game.Players:GetDescendants()) do
if v.Name == "lemessage" or v.Name == "sender" then
v.Visible = true
end
end
end
end
end
end
the prints are just there because I was doing some debugging. if anyone has any idea how to fix this or has a better way of doing then PLEASE let me know.

2 comments
just have the message template in like server storage then clone it and put it in every players playergui
i have been working on this for hours and i cant believe i didn't think of that, THANK YOU SO MUCH