✓ Accepted answer
What you could use is String.match() to place a string into a table into separate arguments. In your case it would be a little something like this:
cmdPrefix = '.'
local admins = {
'AnAdminUsername123',
24829482,
}
function checkAdmin(Player)
for _,v in pairs(admins) do
if type(v) == 'string' and v == Player.Name then
return true
elseif type(v) == 'number' and v == Player.UserId then
return true
end
end
return false
end
function getPlayer(givenString)
if not givenString then return end
local victim = nil
for _,Player in pairs(Players:GetPlayers()) do
if Player.Name:lower() == givenString:lower() then return Player end
if Player.Name:sub(1, #givenString):lower() == givenString:lower() then
victim = Player
end
end
return victim
end
Player.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if checkAdmin(Player) then
local args = {}
for arg in Message:gmatch("%S+") do
table.insert(args, arg)
end
if args[1]:lower() == cmdPrefix..'change' then
local victim = getPlayer(args[2])
if victim then
local stat = args[3]
if victim.leaderstats:FindFirstChild(stat) ~= nil then
stat = victim.leaderstats[args[3]]
end
local value = args[4]
if type[value] == 'number' then
stat.Value = value
end
end
end
end
end)
end)
So let's say an admin would say .change (player) (stat) (value) it would go through all the checks and if they all pass, it should change the players value. Obviously, you can change the if statements accordingly for your script but this is just a template.
I didn't really check this since I am in a hurry so if there are any errors please let me know and I shall try to fix them.
1 comment
We aren't free model support; you should make an attempt