So I need help with cmdr, I have a folder called “data” under the player in game.Players and I want to find all the instances that are any value (e.g. IntValue, BoolValue etc), is there a way to do that?
My current code is below.
local Players = script.Parent.Parent.Parent.Parent:GetService("Players")
return function(_, players, value, change)
for _, player in Players:GetPlayers() do
local playerData = player:FindFirstChild("Data")
if playerData then
local playerValue = playerData:FindFirstChild(value)
if playerValue then
playerValue.Value += change
end
end
end
return("Successfully added onto the players data")
end
Also, sorry if I made it confusing, I want it to find all the objects under the folder that is a value and then return them into cmdr. Though, is there another easier way by like putting “Iron” or “Gold” in the cmdr command? Is that even possible?
More context:
Fill in those boxes with “Iron” and “Gold” text
return {
Name = "add",
Description = "Add onto a player's or a set of players saved data",
Group = "DefaultAdmin",
Args = {
{
Type = "player",
Name = "players",
Description = "The player or players stats you want to edit"
},
function(context)
return {
Type = context.Cmdr.Util.MakeEnumType("option", {"Iron", "Gold"}),
Name = "value",
Description = "What is the name of the data to change?",
}
end,
{
Type = "integer",
Name = "change",
Description = "How much would you like to add onto it?"
},
}
}
The function(context) is what changed this. Leaving this for later readers.