Thanks you a lot brother!
Ok I have 2 solutions for you. First one, you make it so that the player chats twice to make it work. So the first time they type .rename Someone. and then on a second line they type what they want to rename the person too. The second solution is much much worse as you make a list of pre-defined names and these names are the only names that the player can rename the other player to. Tell me which solution you prefer and ill tell you the code for it.
what do you mena with chats twice to make it work?
I meant that they will first chat ā.rename Someoneā
and type enter, and then they will type the new name.
Example:
.rename AAD232007
Somebody
This should change my name to Somebody
Oh I understand, but there is no way to make this only be written once .rename someone newNameHere
I canāt think of any solution Iām sorry. If I find one I will tell you.
Edit: I have an idea, but this will stroll away from the chat commands entirely. My idea is to use a GUI to make this work.
The DisplayName
property on the humanoid has NOTHING to do with the new update coming out soon. DisplayName on the humanoid is just what it shows above a playerās head. Renaming the model will throw an error by the way.
Alright, so Iāve seen your previous post and assume youāre creating an admin system. I was going to respond to this post with the code that you provided, albeit edited on my part. However, I noticed that you seem to be coding your admin system so its rigid and specific. While this isnāt necessarily a bad thing in coding it isnāt what you want to do for an admin system. For an admin system you want to make it so it has a strict structure and dataflow for processing the events and then a modular design for the commands that allows you to easily create new ones. You want to have a system in place to handle the things listed below:
- A listener for whenever a player chats.
- Some sort of parser to process, convert, and filter the data received whenever the player does speak.
- A command module that makes is easy to expand and add new commands (If you ever want to add new commands that is.)
- (optional) A rank system for level of access to commands.
- (optional) Some sort of logger to store event data for the game session.
Of course you donāt have to have all of this. When you are developing something on your own itās what you want to do that matters. These are just tips to help make it easier to develop one. Iāve taken your base code and transformed it into an Admin System to help you get started. You can get it here.
P.S. - If you want me to make it so it Saves your data about who is admin and/or for what names people have then just tell me and Iāll update the module and tell you in this topic when itās been updated.
OMG! That programming is of another level, how long have you been programming? And thank you very much, Iām super interested in the rename part but I donāt know how to implement it in my code, could you help me with that?
P.S. I know how to create modules, the truth is that it is difficult for me to understand your programming, but I could implement mine in a module and it would be much easier for me to understand everything, would this work in the same way?
Iāve been programming in Roblox Lua for around 2-3 years now. Depending on how you structure your module script, yes you will be able to use it (somewhat) the same. The reason I say somewhat the same is because my commands module uses metatables at the end before returning the table so that the logger is able to print the command name easier. Just think of a module script as a table that is independent of your original script. However, using the require() function you are able to use it in any script that can access it. You can find out more about module scripts here.
As a side note, because module scripts return a table you are able able to structure the table like you would an ordinary one. Just as any table, you can arrange it into an array, a dictionary, or mixed version of both. However, most of the time it is more beneficial to structure your table in the form of a dictionary. Also, if you want to know more about metatables you can learn it about it from these resources:
All you need to know about Metatables and Metamethods
Metatables, Metamethods, ModuleScripts and OOP
Metatables can be incredibly hard to wrap your mind around at first but once you get the concept it becomes remarkably easy. Also, part of the code I used to parse through the messages the player chatted used String Patterns. You should learn all the string functions you can because they can be really useful. At the moment however I recommend that you just use the model I provided because itās really easy to create commands for without having to worry about anything else. Youāll need to learn more vanilla Lua API functions and Roblox Lua API in order to create a complex admin system.
Thank you very much indeed! I have a lot to learnā¦ :o
OOPS! Sorry, I just realized that I accidentally forgot to check if the message was a command before attempting to execute the command! My Bad! Iāve updated the model to fix this as well as make the only person with admin the game.CreatorId. You can change this in the main script in the Player.Chatted function by replacing the
if player.UserId == game.CreatorId then
with something else. If you do use the model I provided youāll want to re-add it to your game.