Problems with custom admin

Hello, so I’ve been trying to make a good custom admin for a while. It has been going really smoothly except announcement guis and things that have to do with guis such as :m and stuff. It either has a really big delay or doesn’t even send it at all. This is what I always do:

if cmd:lower() == prefix.."m" then
 for _,players in pairs(game.Players:GetChildren()) do
  local gui = script.Parent.Guis.AnnGui:Clone()
  gui.Parent = players.PlayerGui

Do you guys know how to fix the delays? It works perfectly in studio but not on an actual server.

Hello, I would recommend use RemoteEvent instead.
Servers can lag during looping something, but if you fire cleints with remote event, all perfomance issues will be fixed or atleast reduced. But, don’t think that way works for everything. When you are working with guis, it is better to use RemoteEvent.

So what I should do is to use a local script to detect the commands instead of a server script?

No, you still need detect the command on server and when correct command is being called, you do RemoteEvent:FireAllClients() to make local script create gui on player’s screen.

Alright, thanks for the help much appreciated.