Basic Admin Essentials Promote/Demote Commands

I am trying to create a new command in the Basic Admin Essentials MainModule called demote and promote.
I read a forum post about how to create a rank management system using glitch. So I copied over the server, configs, and main script into one of my games and whenever I run the command promote in the BAE admin console it calls the server and runs the promote command with 2 args (GroupID, UserID).
Currently, when I run it, it gives me the error

Attempt to concatenate Instance with String.

I have no idea how to fix this.

BAE MainModule code:

function Funcs.Promote(Args)
	local Player = Args[1]
	local Command = Args[2]
	local Players = returnPlayers(Player,Args[3],Args[2]) if not Players then return end
	if Command == "promote" then
		for a,b in next,Players do
			local server = require(game.ServerScriptService.Main.Server)
			server.Promote(9832442,Player.UserId)
			essentialsEvent:FireClient(Player,'Hint','Success','Promoted user '..Player.."!")
		end
	elseif Command == "demote" then
		for a,b in next,Players do
			local server = require(game.ServerScriptService.Main.Server)
			server.Demote(9832442,Player.UserId)
			essentialsEvent:FireClient(Player,'Hint','Success','Demoted user '..Player.."!")
		end
	end
end
3 Likes

From what I can see from previous lines, this is a Player Instance, so just do Player.Name instead of Player when concatenating on the last argument, the 1st argument stays the same

1 Like

That is not the problem. Getting the UserID is. But I will definitely fix that.

Are you erroring on the FireClient lines? If so, then it’s cause of the thing I mentioned about trying to concatenate the player instance with a string, when doing ..Player.., you should change it to ..Player.Name..

Also your local server = require(game.ServerScriptService.Main.Server) should be put outside of the function because regardless if you’re promoting or demoting, it’s still using this module

1 Like

Yes I am.

:confused:

Wordsssssssss

1 Like

Then it’s because of the issue I had stated, change your ..Player.. to ..Player.Name.. in both of the FireClients, Player is a variable that contains a Player instance if previous code is anything to go by

Yes, I know but I am trying to get the player’s userID, not the Player’s username.

So what you’re trying to do in that Demoted/promoted user string is to mention the userid?

Something like

Demoted user 674725663!? If so, just change ..Player.. to ..tostring(Player.UserId)..

Im not talking about the hint function. I am talking about the server.Promote and server.Demote

What is wrong with the Promote and Demote? You were saying the error is having in the FireClient lines

Oh I did not know you meant that.

The error with promote and demote is getting the UserID.

What happens if you try to print the UserId of the player given? If you have a Player instance shouldn’t it be easy to get the id?

Yes. But for some reason whenever I get the user ID by using player.UserId it says attempt to concatenate instance with string.

Huh? That’s strange, never saw that happen before, does it even happen if you put a print(Player.UserId) somewhere?

I don’t know. Let me try that real quick! :slight_smile:

Nothing printed. :confused:

dsfjkdsijfsdiofjdosifjaiofjosiafjsoifjsoifj (random words)

Okay it’s something wrong with how it is getting t he Player, what happens if you print the Player variable by itself, aka print(Player)

It prints phyouthcenter1. So it prints the players name

Wait, before anything, add this print, print(typeof(Player)), if it returns string, it’s likely that’s your issue.

Also I just realised your looping is kinda unnecessary

ok.

fdskjfjisefjsejkfsjdkfjkdsjkfdsjkfdsjkfjkdsjkfasjkfjkdsjkfsd