So, I’m creating an admin commands script, and I’m trying to make it so when a player states “/commands” or something, a notification will pop up showing the list of commands. I’m currently using a script in SSS to fire the event, and then in starter GUI that’s where it gets the OnClientEvent. Any suggestions?
SSS_CODE
elseif Message == "/help" or Message == "/commands" or Message == "/cmds" then
local CommandsList = {
"/kick [player] - Kicks a player.",
"/ban [player] - Bans a player.",
"/unban [player] - Unbans a player.",
"/mute [player] - Mutes a player.",
"/unmute [player] - Unmutes a player.",
"/jumppower [number] - Changes your jump power to the number specified.",
"/kill[player]- Kills the target",
"/respawn[player]- Respawns the target",
"/gameban[player][reason]- Bans the user from joining even when server restarts."
}
game.ReplicatedStorage.Notification:FireClient("COMMANDS",CommandsList)
STARTERGUI_SCRIPT_LOCAL
game.ReplicatedStorage.Notification.OnClientEvent:Connect(function()
local startergui = game:GetService("StarterGui")
startergui:SetCore("SendNotification", {
Title = "NOTIFICATION",
Text = ""
})
end)
Well your issue in the server script is that you need to mention a client (player instance) in the first argument here Like: game.ReplicatedStorage.Notification:FireClient(Client, "COMMANDS",CommandsList) to send it to the client
That ended up sending a notification; however, the notification doesn’t have what I wanted on it.
It doesn’t have the title and the list of commands. ("COMMANDS", CommandsList) is what I want in the notification. COMMANDS being title, and then CommandsList being commands.
It’s hard to explain. I want it so game.ReplicatedStorage.Notification:FireClient("COMMANDS",CommandsList) shows what I would like on the notification; however, I am unsure on how to do that.
I need you to explain more. Can you provide an example what would be on the notification. “When Player does this > This Shows up On the Notification”. I need as much info as I can get. Its unclear to me right now because I was given a lack of information when some info could be really helpful to what you want to excute
#2: Inside your local script, you are not putting anything into the Text variable which you need to do. So, something like this:
game.ReplicatedStorage.Notification.OnClientEvent:Connect(function(Type, CommandsList)
local startergui = game:GetService("StarterGui")
local text = ""
if Type == "COMMANDS" then
for _, command in pairs(commands) do
text = text .. "\n"..command
end
end
startergui:SetCore("SendNotification", {
Title = "NOTIFICATION",
Text = text
})
end)
Hopefully this helps! Here is the documentation for what I used.
You will want to go to that command itself and do something like:
--Player Name is the Name of the player given in the command
if game.Players:FindFirstChild(PlayerName) then
--Run Code to do command
else
`game.ReplicatedStorage.Notification:FireClient(Client, "COMMANDS", "Player is Invalid")`
end
Alright. What you can do is place my answer as the solution, then create a new thread addressing the errors, along with BOTH scripts in their entirety.
Also pairs and ipairs are kinda deperated, Its not and is at the same time… If I remember correctly, Roblox wants users to start Using ’ for _, command in CommandsList do’ and just remove it. I myself find this hard to adapt to it too, and I doubt roblox would ever remove it, but yea. Just an intresting fact