Admin giving gui

How am I able for a person to click a player then a button and it’ll give the selected player temp moderator. Here is the script I’ve got so far;

local clic = Instance.new("ClickDetector")
clic.Parent=script.Parent
local capt = game.StarterGui.PlayerINFO.Role_Assignment.Input.Frame:WaitForChild('Captain')
local FO = game.StarterGui.PlayerINFO.Role_Assignment.Input.Frame:WaitForChild('First Officer')
local FA = game.StarterGui.PlayerINFO.Role_Assignment.Input.Frame:WaitForChild('Flight Attendant')
local GA = game.StarterGui.PlayerINFO.Role_Assignment.Input.Frame:WaitForChild('GateAgent')
local GC = game.StarterGui.PlayerINFO.Role_Assignment.Input.Frame:WaitForChild('Ground Crew')
local CH = game.StarterGui.PlayerINFO.Role_Assignment.Input.Frame:WaitForChild('Co-host')

function onClicked(plr)
	local name = clic.Parent.Name
	local playr = name
	if plr then
		local gui = plr:FindFirstChild("PlayerGui")
		if gui then
			local text = gui:FindFirstChild("PlayerINFO")
			if text then
				text.Role_Assignment.Input.Text= name
			end
		end
	end
end
clic.MouseClick:Connect(onClicked)

script.capt.MouseButton1Click:connect(function(click)
	local player = game.Players:GetPlayerFromCharacter(click.Parent)
	local plrname = tostring(player.Name)
	local server = getfenv(_G.Adonis.Access("e","Admin").GetLevel).server
	server.Admin.RunCommand("mod",plrname)
end)

script.FO.MouseButton1Click:connect(function(click)
	local player = game.Players:GetPlayerFromCharacter(click.Parent)
	local plrname = tostring(player.Name)
	local server = getfenv(_G.Adonis.Access("e","Admin").GetLevel).server
	server.Admin.RunCommand("mod",plrname)
end)

script.FA.MouseButton1Click:connect(function(click)
	local player = game.Players:GetPlayerFromCharacter(click.Parent)
	local plrname = tostring(player.Name)
	local server = getfenv(_G.Adonis.Access("e","Admin").GetLevel).server
	server.Admin.RunCommand("mod",plrname)
end)

script.GA.MouseButton1Click:connect(function(click)
	local player = game.Players:GetPlayerFromCharacter(click.Parent)
	local plrname = tostring(player.Name)
	local server = getfenv(_G.Adonis.Access("e","Admin").GetLevel).server
	server.Admin.RunCommand("mod",plrname)
end)

script.GC.MouseButton1Click:connect(function(click)
	local player = game.Players:GetPlayerFromCharacter(click.Parent)
	local plrname = tostring(player.Name)
	local server = getfenv(_G.Adonis.Access("e","Admin").GetLevel).server
	server.Admin.RunCommand("mod",plrname)
end)

script.CH.MouseButton1Click:connect(function(click)
	local player = game.Players:GetPlayerFromCharacter(click.Parent)
	local plrname = tostring(player.Name)
	local server = getfenv(_G.Adonis.Access("e","Admin").GetLevel).server
	server.Admin.RunCommand("Admin",plrname)
end)

For some reason, this doesn’t work at all. It doesn’t select the player, the select player script is at the top. Here is my workspace.
image

3 Likes

There isnt anything in the out put.

1 Like

Try using a server script instead of a local script.

1 Like

The select player part wont work then.

1 Like

What do you mean by that? :thinking:

1 Like

The person who is pressing the button, needs to click a player for their name to appear on a GUI.
After it appears on the GUI, you will be able to press any button on the GUI and depending on the button you will get the respected admin.