Need help with cmdr - finding values

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

Thanks yall :heart:

did you know you can do game instead
also you dont even need this;

just do
for _, player in players do

You just wanna find the keyword “value” in the objects classname

for i,v in pairs(data:GetChildren()) do
   if string.find(v.Classname,”Value”) then print(“Current object is a value”) end
end

oof, wasn’t thinking straight

Where would I put that?

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:
image
Fill in those boxes with “Iron” and “Gold” text

Still requesting help on this, I have read some of the docs but nothing I see helps.

Link:

I ended up fixing it by doing this:

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.