Hello Devs!
I’m making Admin commands but I want to make some arguments normal.
I uses string.lower() and it makes all string small but in stat command when I type:
/add {username} {StatType} {Amount}
StatType is small and script can’t find a stats.
Here is script:
local commands = {}
local prefix = "/"
local admins = {
226087810; -- R05HX
1583088521; -- Simongracz
}
local function findPlr(name)
for i, player in pairs(game.Players:GetPlayers()) do
if string.lower(player.Name) == name then
return player
end
end
return nil
end
local function isAnAdmin(plr)
for _, v in pairs(admins) do
if v == plr.UserId then
return true
end
end
return false
end
-- Add Stat Value
commands.add = function(sender, arguments)
local PlrToGive = arguments[1]
local Currency = arguments[2]
local Amount = arguments[3]
if PlrToGive and Currency and Amount then
local PlrToG = findPlr(PlrToGive)
if PlrToG then
PlrToG.leaderstats[Currency].Value += tonumber(Amount)
end
end
end
game.Players.PlayerAdded:Connect(function(plr, arguments)
if isAnAdmin(plr) then
plr.Chatted:Connect(function(msg,recipient)
msg = string.lower(msg) -- makes every string small
local splitString = msg:split(" ")
local slashcmd = splitString[1]
local cmd = slashcmd:split(prefix)
local cmdName = cmd[2]
if commands[cmdName] then
local arguments = {}
for i = 2, #splitString, 1 do
table.insert(arguments, splitString[i])
end
commands[cmdName](plr,arguments)
end
end)
end
end)
Output error: speed is not a valid member of Folder "Players.R05HX.leaderstats"