Basic Admin Help

Hi there. Im in needing some help scripting a basic admin plugin.

I dont really know how to script, i know some things but its all beginner stuff.

Im trying to script a command so that I can temporarily change a players overhead GUI to what ever the admin inputs. For example, :role exquicvs test

and it would change the section in my overhead rank gui to “test” instead of my group rank “president”

If someone could help me script this, heres my current code, its really just a refined version of the plugin example, but its a start i guess?

local Plugin = function(...)
	local Data = {...}
	
	-- Included Functions and Info --
	local remoteEvent = Data[1][1]
	local remoteFunction = Data[1][2]
	local returnPermissions = Data[1][3]
	local Commands = Data[1][4]
	local Prefix = Data[1][5]
	local actionPrefix = Data[1][6]
	local returnPlayers = Data[1][7]
	local cleanData = Data[1][8] -- cleanData(Sender,Receiver,Data)
	-- Practical example, for a gui specifically for a player, from another player
	-- cleanData(Sender,Receiver,"hi") -- You need receiver because it's being sent to everyone
	-- Or for a broadcast (something everyone sees, from one person, to nobody specific)
	-- cleanData(Sender,nil,"hi") -- Receiver is nil because it is a broadcast
	
	-- Plugin Configuration --
	local pluginName = 'role'
	local pluginPrefix = Prefix
	local pluginLevel = 2
	local pluginUsage = "<User(s)> <Role>" -- leave blank if the command has no arguments
	local pluginDescription = "Change a players role"
	
	-- Example Plugin Function --
	local function pluginFunction(Args) -- keep the name of the function as "pluginFunction"
		local Player = Args[1]
		if Args[3] then
			local Victims = returnPlayers(Player, Args[3]) if not Victims then return end
			local combinedVictims = ''
			for a,b in pairs(Victims) do
				if combinedVictims == '' then
					combinedVictims = b.Name
				else
					combinedVictims = combinedVictims..', '..b.Name
				end
			end
			for a,b in next,Victims do
				remoteEvent:FireClient(b,'Hint','Aauvi Administration','Secuessfully changed the specified players role.',{'Message','Results',combinedVictims})
			end
		end
	end
	
	-- Return Everything to the MainModule --
	local descToReturn
	if pluginUsage ~= "" then
		descToReturn = pluginPrefix..pluginName..' '..pluginUsage..'\n'..pluginDescription
	else
		descToReturn = pluginPrefix..pluginName..'\n'..pluginDescription
	end
	
	return pluginName,pluginFunction,pluginLevel,pluginPrefix,{pluginName,pluginUsage,pluginDescription}
end

return Plugin

i created the message part where it tells u like it secuessfully did it, although i need help with the part that actually changes the role

thanks

Ok, so thinking about this logically, break down each step of what you need to do.
You say you want to change the overhead rank GUI to what role you want it to be. Breaking it down, you’ll probably need to:

  • Get the specified player
  • From there, get the character of that player
  • Find the GUI in the character
  • Change what it says in that GUI. You could use a lookup table to check what value this needs to be, so you could maybe do custom text colors per rank.

Ok, now let’s go through each step.

  • Get the specified player

Getting the specified player is easy enough. Assuming you have the name of the player:

local SpecifiedPlayerName = "someone"
local SpecifiedPlayer
for i, v in pairs(game:GetService("Players"):GetPlayers()) do
    if v.Name == SpecifiedPlayerName then
        -- You have the player
        SpecifiedPlayer = v
        break
    end
end
-- The specified player did not exist, raise an error
  • Get the character of that player

Even simpler.

local Character = SpecifiedPlayer.Character
  • Find the GUI in the character
local GUI = Character.Head:FindFirstChild("RankGUI")

Again, super simple.

  • Change what it says in the GUI.

You could go two ways with this:

  1. Put the argument right into the GUI text.
  2. Use a lookup table to get the rank and put the text from that.

super confused. so i paste this in the plugin code? if so where? i dont have much experience scripting, so this is all very new to me. although i’m willing to learn!

Pasting in the code won’t work. The code I gave are little example snippets that you can use to get your answer. Is this your framework you’ve made? All you need to do is adapt the code so it works in your framework. I’m not sure how you will, since I don’t know your framework.

I don’t want to spoonfeed either - if I just give you the answer, and you paste it in and it works - you will not learn anything, and you won’t get better at scripting.

I’ll give you a hint, though:

From the comments, pluginFunction is what gets executed when the command runs.
Inside, near the bottom, you have this loop:

for a,b in next,Victims do
	remoteEvent:FireClient(b,'Hint','Aauvi Administration','Secuessfully changed the specified players role.',{'Message','Results',combinedVictims})
end

In this loop, you have two variables: a and b. I don’t know what a is, but b is a player object. You can rename it to Player or similar to help you keep track of what it is. I suggest you do this, especially as a beginner coder. (Another suggestion: use comments to leave notes around your code. This will help you a lot.)

Anyway, from here, because you have your player, you can follow my snippets from my second snippet. Get the player’s character, then find the Head using Character:FindFirstChild("Head") (since I’ll bet that’s where your rank GUI is), then find the TextLabel which has the rank name in it, and change it to the rank name, which as far as I can tell, is stored in the Args table, with the index being 2 probably.