I'm currently making custom admin commands. One of the commands I'm making is "/menu" command where when you say the command, it has a gui come onto the sender's gui. For some reason, this is not working. Help?
Heres my script:
local commands = {}
local prefix = "/"
commands.menu = function(sender)
local name = sender.Name
local gui = script.MenuGui:Clone()
gui.Parent = game.Players.name.PlayerGui
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message,recipient)
message = string.lower(message) --if someone says "Menu" or the command with any uppercase letters, it would be converted into lowercase lol
local splitString = message:split(" ")
local slashCommand = splitString[1]
local cmd = slashCommand:split(prefix)
local name = cmd[2]
if commands[name] then
commands[name]()
end
end)
end)
Any help would be appreciated.

4 comments
No, you can't acces the player GUI through a script.... but can you help me here? my roblox animation won't play through the actual game.. it only plays in Roblox Studio...
"Name" is equal to the player's name, not the command name. You also are using the incorrect format to use GUIs in a script.
You should use events when doing this so player is defined for finding playergui
like when firing the server put player in the brackets ()