[SOLVED] I need help with a cmdr command using Number values

Firstly, don’t place the print in the for loop. Place it before the for loop (as in, on the second line)

Secondly, you didn’t change the line that I said to change lol

this is what I meant:

return function (_, players, clanname, clans: string)
	print(clanname)
	for _, player in pairs(players) do
	local character = player.Character
		if character then
			local Clanfolder = game.ReplicatedStorage:WaitForChild("Clans")
			local ClanValue = character:WaitForChild("Clan")
			if ClanValue then
				if ClanValue.Value ~= "none" then
					local Clans = ClanValue
					if Clans then
						player.Character.Clan.Value = Clanfolder[clanname].Value
					end
				end
			end
			return ("Assigned clan to Player."):format(#players)
		end
	end
end

Nope, I got the same error.

(please ignore that person lol)

Firstly, can you show me the entire console? I want to see if the print actually printed anything. Secondly, I believe the issue currently is that clanname is actually a folder (strange), in which case try changing it to “clans” instead (the lowercase one)

It didn’t printed this time sadly.

2
Console

return function (_, players, clanname, clans: string)
	print(clanname)
	for _, player in pairs(players) do
		local character = player.Character
		if character then
			local Clanfolder = game.ReplicatedStorage:WaitForChild("Clans")
			local ClanValue = character:WaitForChild("Clan")
			if ClanValue then
				if ClanValue.Value ~= "none" then
					local Clans = ClanValue
					if Clans then
						player.Character.Clan.Value = Clanfolder.Value
					end
				end
			end
			return ("Assigned clan to Player."):format(#players)
		end
	end
end

The code

Strange. try replacing every instance of “clanname” in the script with “clans” instead

also, yet again, change “Clanfolder.Value” to “Clanfolder[clans].Value”. That is very very important!!!

return function (_, players, clanname, clans: string)
	for _, player in pairs(players) do
	local character = player.Character
		if character then
			local Clanfolder = game.ReplicatedStorage:WaitForChild("Clans")
			local ClanValue = character:WaitForChild("Clan")
			if ClanValue then
				if ClanValue.Value ~= "none" then
					local Clans = ClanValue
					if Clans then
						player.Character.Clan.Value = Clanfolder[clans].Value
					end
			end
			end
			return ("Assigned clan to Player."):format(#players)
			
		end
	end
end

This is my original script and it works like I showed you before, but it shows the folder name, about the “clanname” is nothing, it doesn’t have anything added.

1 Like

ok yea copy this exact script

return function (_, players, clanname, clans: string)
	for _, player in pairs(players) do
	local character = player.Character
		if character then
			local Clanfolder = game.ReplicatedStorage:WaitForChild("Clans")
			local ClanValue = character:WaitForChild("Clan")
			if ClanValue then
				if ClanValue.Value ~= "none" then
					local Clans = ClanValue
					if Clans then
						player.Character.Clan.Value = Clanfolder[clans].Value
					end
			end
			end
			return ("Assigned clan to Player."):format(#players)
			
		end
	end
end

(not much change lol)

Here lol.

wait do each of those string values not have values?

ok use this ig

return function (_, players, clanname, clans: string)
	for _, player in pairs(players) do
	local character = player.Character
		if character then
			local Clanfolder = game.ReplicatedStorage:WaitForChild("Clans")
			local ClanValue = character:WaitForChild("Clan")
			if ClanValue then
				if ClanValue.Value ~= "none" then
					local Clans = ClanValue
					if Clans then
						player.Character.Clan.Value = Clanfolder[clans]
					end
			end
			end
			return ("Assigned clan to Player."):format(#players)
			
		end
	end
end

Same error sadly, Let me show you everything of how is this script made and well, the folder and the string value location.

Original script (Works) but doesn’t show clan names, only folder name.

return function (_, players, clanname, clans: string)
	for _, player in pairs(players) do
	local character = player.Character
		if character then
			local Clanfolder = game.ReplicatedStorage:WaitForChild("Clans")
			local ClanValue = character:WaitForChild("Clan")
			if ClanValue then
				if ClanValue.Value ~= "none" then
					local Clans = ClanValue
					if Clans then
						player.Character.Clan.Value = Clanfolder.Name
					end
			end
			end
			return ("Assigned clan to Player."):format(#players)
			
		end
	end
end

This is the string value where it should give the name of the clan, but gives the folder name.
2

And this is the folder location, clans and names of clans.
1

yea uh

return function (_, players, clanname, clans: string)
	print(clans)
	for _, player in pairs(players) do
	local character = player.Character
		if character then
			local Clanfolder = game.ReplicatedStorage:WaitForChild("Clans")
			local ClanValue = character:WaitForChild("Clan")
			if ClanValue then
				if ClanValue.Value ~= "none" then
					local Clans = ClanValue
					if Clans then
						player.Character.Clan.Value = Clanfolder.Name
					end
			end
			end
			return ("Assigned clan to Player."):format(#players)
			
		end
	end
end

and tell me what it prints

It shows and printed nil in the console.

interesting… yet when you print clanname you get an entire table?

try removing the clanname argument completely, I’m really confused on whats happening tbh lol

I removed the clanname and is still the same, works but with the folder name, and this is the print.

Code

return function (_, players, clans: string)
	print(clans)
	for _, player in pairs(players) do
		local character = player.Character
		if character then
			local Clanfolder = game.ReplicatedStorage:WaitForChild("Clans")
			local ClanValue = character:WaitForChild("Clan")
			if ClanValue then
				if ClanValue.Value ~= "none" then
					local Clans = ClanValue
					if Clans then
						player.Character.Clan.Value = Clanfolder.Name
					end
				end
			end
			return ("Assigned clan to Player."):format(#players)

		end
	end
end

ok wait gtg help u later

charactersdhaskdhaskjdhasjkhdasdas

Rip, but thanks, you helped me with the other, Ima check if someone else can help me too.

1 Like

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