So I make a chat command, is there a way for local player can change the prefix according to how they want? Maybe they can use command !changeprefix and after that they can use the prefix according to what they change it to be
By prefix do you mean changing what they need to say to activate the command??
If so then it can be done by having a variable holding what it is changed to and then checking what command to run first check if an alternative prefix exists for that command and if it does see if the text matches that.
Using the same kind of thing you could even make your own commands within the game from loadstring and save both the prefix and attach code to the prefix using loadstring
How I usually do it is I use:
Player.chatted:Connect(function(msg)
Then you would use string.split() to split it into segments for the different arguments. I would do a little research on what string.split does and how to use it with commands.
Also check out string.lower() What that does is it makes the string lowercase. This is good because it makes the command not case sensitive.
I’m not very experienced in chat commands. I’ve done a few but I do better with admin pannels to be honest. But that’s just some advice I’ve picked up over time that I thought would be useful.
Have a nice day!
you could set a variable to a string with your default prefix and then using the split string system to do the command. for example
local prefix = "!"
if message == (prefix.."Test") then
I didn’t make the full script just a part of it but then by doing this you could create a changeable prefix by just replacing the variable later on.
No, that’s not what I meant, what I mean is usually you already set on the module or the script right? But what I want is every player can change their prefix, so let’s say there are 3 players, default prefix is “!” But player 2 want to change the prefix using “!changeprefix ;” , i want after this happen, the next time, player 2 can just run command using “;”
So then you could just store their prefix as a variable in a module or datastore and do exactly the same thing.
local ms_ = require(modulescript)
local pattern = "!changeprefix %p"
if message == string.match(message, pattern, 1) then
ms_.prefix = string.split(message, " ")[2]
local prefix = "!"
Player.chatted:Connect(function(msg)
local FormatMessage = string.lower(message)
if message == (prefix.."test") then
-- code here
end
end)