Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I need Help with making an command. Like I have commands but this one I can’t seem to figure out?

Asked by 1 year ago

Ok so some commands but they’re one I can’t figure out, ii want a command where when you say !enroll blahblah133 it puts a randomly generated schedule for classes. (By the way this is a school). I know this is hard so I understand is no one can do this

1 answer

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
1 year ago
Edited 1 year ago

Hello, Youtuber_212121!

I'm not going to give the full code, just instructions on how you can make this.

First of all, you should use the player.Chatted event to detect when a player writes any message in chat. The event passes in arguments the player and the message that was sent.

The documentation I provided has some explanation and code for chat commands, I'm going to put it here, but I recommend looking at the documentation.

Chat Commands

Using this event and some string manipulation functions like string.sub() and string.lower(), it is possible to create chat commands, even with arguments like player names. Usually, commands are prefixed such as heal PlayerName. To check for a prefix in a string, use string.sub() on the message to check a substring of the message: string.sub(message, 1, 6) == "/heal " (note the inclusion of the space) . Then, extract the rest of the command using string.sub() again: string.sub(message, 7) will be equal to the player name. Check if that player exists, and if so, perform the command's action (in this example, healing them). Check the code samples for examples of chat commands.

- Player | Roblox Creator Documentation

Edit: Re-reading your question, it seems like you already have commands, I assume that you are using a pre-made admin, if so, please provide the admin script name so I can provide a solution using it, instead of default roblox functions


If this answers your question, please mark it as the Accepted Answer

Ad

Answer this question