#How can I create a admin command for my staff to adjust players stats
1 messages · Page 1 of 1 (latest)
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
You mean in chat?
https://create.roblox.com/docs/reference/engine/libraries/string
you would also need string formatting
** You are now Level 2! **
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)
stop spoonfeeding
I didn't really need a spoonfeed, but that wouldn't work anyway as that only adjusts leader stats, that doesn't increase the value of any other currency we have