I'm attempting to make a set of admin commands, and the first I'm attempting is the message command, but when I attempted it, it mixes the string and player variables when I attempt to match them from the string..
When I say "message player1 Hello dude",
Output:
Original message: message player1 Hello dude
PLAYER: player1 Hello
STRING: dude
Sending "dude" to "player1 Hello"
Sender Script:
game.Players.PlayerAdded:connect(function(newPlayer)
print("Player Entered")
newPlayer.Chatted:connect(function(msg)
print("Original message:",msg)
game.ReplicatedStorage.ChatEvent:FireServer(newPlayer.Name,msg)
end)
end)
Admin script:
local admin = "player1"
function onchat(newPlayer,message)
print('Chat')
if newPlayer:lower() == Admin then --I'm aware of the fact I can use tables for this, just not doing that yet.
print'Admin'
if string.sub(string.lower(message),1,8) == "message " then
local player = message:match("^message%s%s*(.+)%s")
print("PLAYER:",player)
local strin = message:match("^message%s"..player.."%s*(.+)")
print("STRING:",strin)
end
end
end
game.ReplicatedStorage.ChatEvent.OnServerEvent:connect(function(playerTheServerSends,player,message)
onchat(player,message)
print("Message:",message)
end)
Any help is appreciated.

2 comments
Where did you learn the codes like "%s%s*(.+)%s"?
^ From BlueTaslem