So, I am making this admin script where everything goes very well. My only problem is that I can't seem to choose which strings I want to read. I've used stuff like message:sub(4, 6) to get different characters, but when it comes to finding the player name entered I can't determine how long the player name will be. I need this information to get the strings coming behind the character name. An example is: /warn WaterFoox "REASON". I want to get the reason for why they got warned and put it into a frame that warns them. I've read on the wikis, but I don't really understand the explanation of whats listed here: https://developer.roblox.com/articles/Lua-Libraries/string#string.sub
Here are some of my code:
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(message)
for i, admin in pairs(Admins) do
if plr.Name == admin then
message = string.lower(message)
if message:sub(1, 6) == "/warn " then
for _,player in pairs(game:GetService("Players"):GetPlayers()) do
if message:sub(7) == player.Name:sub(1,message:sub(7):len()):lower() then
if player then
local TheWarn = Warn:Clone()
TheWarn.Frame.Frame.MSGTEXT.Message.Text = message:sub(8)
TheWarn.Parent = player.PlayerGui
TheWarn.Frame:TweenPosition(UDim2.new(0.34, 0,0.362, 0), "Out", "Quint", 3)
wait(10)
TheWarn.Frame:TweenPosition(UDim2.new(0.34, 0,1, 0), "Out", "Quint", 3)
print("Warned " .. player.Name)
end
end
end
end
end
end)
end)
I would appreciate an explanation of what I need to use and please comment anything I should change in my script. I'll be happy with everything I get!
Thanks in advance!
~WaterFoox

1 comment
Thank you so much! This reply is better than I could ever imagine. Now I'll dig down into the wikis for help with string patterns and I'll of course watch the videos! Thank you!