I am trying to make a command that the people listed as Admin below can run to change a certain player's stage number. When I use the script, instead of setting the player's stage to the number, it resets it to zero and gives no errors for me to go off of. I'm new to scripting, so any help would be appreciated.
local Admins = {
90188191;
87578761;
269848417;
}
local Prefix = ";"
local Players = game:GetService("Players")
local Commands = {}
Commands.set = function(Sender, Arguments)
local Username = Arguments[1]
table.remove(Arguments,1)
local Number = Arguments[2]
local Stage = game.Players[Username].leaderstats.Stage
Stage.Value = Number
end
local function IsAdmin(Player)
for _,Admin in pairs (Admins) do
if type(Admin) == "string" and string.lower(Admin) == string.lower(Player.Name) then
return true
elseif type(Admin) == "number" and Admin == Player.UserId then
return true
end
end
return false
end
local function ParseMessage(Player,Message)
local PrefixMatch = string.match(Message,"^"..Prefix)
if PrefixMatch then
Message = string.gsub(Message,PrefixMatch,"",1)
local Arguments = {}
for Argument in string.gmatch(Message,"[^%s]+") do
table.insert(Arguments,Argument)
end
local CommandName = Arguments[1]
table.remove(Arguments,1)
local CommandFunc = Commands[CommandName]
if CommandFunc ~= nil then
CommandFunc(Player,Arguments)
end
end
end
Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message,Recipient)
if not Recipient and IsAdmin(Player) then
ParseMessage(Player,Message)
end
end)
end)

1 comment
the command I am trying to run is ;set [Username] [Value]