Does anyone know how to make a command in this format?
/add person money 100
i need to know basically how to make this detect when a word is over.
local arguement = string.sub(msg, 6,?)
This is what i have right now. Sorry if this is very messy.
local admins = {
1416574751
}
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if table.find(admins,player.UserId) then
if string.sub(msg, 1, 5) == "/add " then
local arguement = string.sub(msg, 6)
local stat = string.sub(msg,string.len(arguement)+2)
local amount = string.sub(msg,string.len(stat)+2)
if string.len(arguement)>=3 then
for i,v in pairs(game.Players:GetChildren()) do
if (string.match(string.lower(v.Name),string.lower(arguement)) or string.match(string.lower(v.DisplayName),string.lower(arguement))) and stat ~= nil and amount ~= nil then
v.leaderstats[stat].Value = amount
local clone = game.ReplicatedStorage.AdminNotification:Clone()
clone.Parent = player.PlayerGui.Ui
clone.TextLabel.Text = "set "..v.Name.."'s "..stat.." to "..amount
clone.TextLabel.TextColor3 = Color3.fromRGB(255,255,255)
elseif stat == nil then
local clone = game.ReplicatedStorage.AdminNotification:Clone()
clone.Parent = player.PlayerGui.Ui
clone.TextLabel.Text = "please provide a message like '/stat name money 100'"
clone.TextLabel.TextColor3 = Color3.fromRGB(255,0,0)
elseif amount == nil then
local clone = game.ReplicatedStorage.AdminNotification:Clone()
clone.Parent = player.PlayerGui.Ui
clone.TextLabel.Text = "please provide a message like '/stat name money 100'"
clone.TextLabel.TextColor3 = Color3.fromRGB(255,0,0)
else
local clone = game.ReplicatedStorage.AdminNotification:Clone()
clone.Parent = player.PlayerGui.Ui
clone.TextLabel.Text = "there is no player under the name of '"..arguement.."'"
clone.TextLabel.TextColor3 = Color3.fromRGB(255,0,0)
end
end
else
local clone = game.ReplicatedStorage.AdminNotification:Clone()
clone.Parent = player.PlayerGui.Ui
clone.TextLabel.Text = "please provide a more specific name"
clone.TextLabel.TextColor3 = Color3.fromRGB(255,0,0)
end
end
end
end)
end)