#How can I create a admin command for my staff to adjust players stats

1 messages · Page 1 of 1 (latest)

weak geyser
#

How can I create a admin command for my staff to adjust players stats

#

Currently us devs use this command to adjust values in console but I want to turn that into a admin command users can use

#

such as !Adjust (User) (Stat e.g. CandyCorn) (value)

#

add dont just go

#

" add Hd it comes with that command, HD add command doesn't work for my currency values for some reason

flint mauve
#

You mean in chat?

hollow prairieBOT
#

studio** You are now Level 2! **studio

jaunty garden
#
local Players = game:GetService("Players")
local admins = {"Admin1PlayerUserName"} -- here put game admins usernames

local function onChatMessageReceived(player, message)
    if not table.find(admins, player.Name) then
           return
    end
    local prefix = "!" -- Change this to your desired prefix
    local args = string.split(message, " ")

    if args[1] == prefix.."Adjust" and #args == 4 then
        local targetPlayer = args[2]
        local stat = args[3]
        local value = tonumber(args[4])

        if targetPlayer and Players:FindFirstChild(targetPlayer) then
            local leaderstats = Players[targetPlayer]:FindFirstChild("leaderstats")

            if leaderstats and leaderstats:FindFirstChild(stat) then
                leaderstats[stat].Value = value
            else
                print("Invalid stat or player does not have leaderstats.")
            end
        else
            print("Invalid target player.")
        end
    end
end

Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        onChatMessageReceived(player, message)
    end)
end)
weak geyser