How do I make Players a choice to choose

add this:

local selectionColor = Color3.fromRGB(255, 0, 0) --pick the color you want
local defaultColor = Color3.fromRGB(255, 255, 255) --pick the current color

for _, i in pairs(list:GetChildren()) do
    i.BackgroundColor3 = defaultColor
end

v.BackgroundColor3 = selectionColor

under target = v.Text in the local script

tysm
so this might get annoying,tell me if you can’t help me but I think you’re the only one that can
So I made this script like years ago and now im basically a noob at scripting.
Below are my script and I used to have this typing box to type ‘!kill all’ and more,but now I wanna click buttons instead,can you help me move all this script to make the buttons functionable? TYSM!!!


local rs = game:GetService(‘ReplicatedStorage’)

local commandEvent = rs:WaitForChild('CommandEvent')



local frame = script.Parent.Commands

local freeze = frame.Freeze
local freeze = frame.Unfreeze
local hide = frame.Hide
local jump = frame.Jump
local kill = frame.Kill
local show = frame.Show
local speed = frame.Speed
local TPelse = frame.TPelse
local TPme = frame.TPme
local trail = frame.Trail
local player = frame.List

local box = frame.Output


--list of valid commands

local actions = {



	'Kill' , 'Freeze' , 'Unfreeze' , 'Hide' , 'Show' , 'Speed', 'Jump',

	'Trail', 'TPto', 'TPhere'



}



local needValue = {



	'Speed', 'Jump'



}



--make sure command is valid

local function valid_command(action)

	for _,command in pairs(actions) do

		if command == action then

			return true

		end

	end

end



--make sure player exists

local function valid_player(person)

	local player_table = {}



	if person == 'me' then

		local player = game.Players.LocalPlayer

		table.insert(player_table, player)

	elseif person == 'all' then

		player_table = game.Players:GetChildren()

	elseif person == 'noobs' then

		player_table = game.Players:GetChildren()

		for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do

			for pos, plr in pairs(game.Players:GetChildren()) do

				if admin.Name == plr.Name then

					table.remove(player_table, pos)

				end

			end

		end

	else

		local player = game.Players:FindFirstChild(person)

		if player then

			table.insert(player_table, player)

		else

			return false

		end

	end



	return player_table

end



local function valid_value(action, value)

	for _,command in pairs(needValue) do

		if command == action then

			if not value then

				return false

			end

		end

	end



	return true

end



--takes command and splits it up

local function get_command()

	local command = {}

	for word in string.gmatch(box."%S+") do

		table.insert(command, word)

	end

	local action = command[1]

	local person = command[2]

	local value = command[3]



	box.Text = ''



	if valid_command(action)then

		local player_table = valid_player(person)

		if player_table then

			if valid_value(action, value) then

				commandEvent:FireServer(action, player_table, value)

			else

				box.Text = 'Value Error'

			end

		else

			box.Text = 'Invalid Player'

		end

	else

		box.Text = 'Invalid Command'

	end



end

EDIT:yea this sounds stupid

So you want to add:

‘Kill’ , ‘Freeze’ , ‘Unfreeze’ , ‘Hide’ , ‘Show’ , ‘Speed’, ‘Jump’, ‘Trail’, ‘TPto’, ‘TPhere’

Commands as buttons?

yea,they are already buttons according to my pic but I just don’t know how to fix the old script in order to make the buttons functionable (replaces the old system[Ex.types in box !kill all]

You just need to put it in the serverscriptservice, add a remote event and fire it with correct arguments (ofc u need to edit a bit the script), ill try to do something

script is alr in ServerScriptService and a remote event called ‘CommandEvent’ have been made,
if that’s what I have to do,the only thing left is to fire the script with right arguments and that’s the thing I’m struggling about.

EDIT:I’ll hope that you’re just eating lunch instead of sleeping…

im making the code, do you have the old server side of this?
i also need a sreenshoot of the buttons location and script location in the explorer


Is this what u want?

nop, i need the old server script u used for it and a screenshot with the new objects in the explorer


[From Top to Bottom]
Kill:Ur script
User:My script to recognize admins
Admin (GUI):Old Admin Panel
Admin2 (GUI):New Admin Panel
Admin Commands:

local rs = game:GetService('ReplicatedStorage')

local commandEvent = rs:WaitForChild('CommandEvent')



local frame = script.Parent.Commands

local freeze = frame.Freeze
local freeze = frame.Unfreeze
local hide = frame.Hide
local jump = frame.Jump
local kill = frame.Kill
local show = frame.Show
local speed = frame.Speed
local TPelse = frame.TPelse
local TPme = frame.TPme
local trail = frame.Trail
local player = frame.List

local box = frame.Output


--list of valid commands

local actions = {



	'Kill' , 'Freeze' , 'Unfreeze' , 'Hide' , 'Show' , 'Speed', 'Jump',

	'Trail', 'TPto', 'TPhere'



}



local needValue = {



	'Speed', 'Jump'



}



--make sure command is valid

local function valid_command(action)

	for _,command in pairs(actions) do

		if command == action then

			return true

		end

	end

end



--make sure player exists

local function valid_player(person)

	local player_table = {}



	if person == 'me' then

		local player = game.Players.LocalPlayer

		table.insert(player_table, player)

	elseif person == 'all' then

		player_table = game.Players:GetChildren()

	elseif person == 'noobs' then

		player_table = game.Players:GetChildren()

		for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do

			for pos, plr in pairs(game.Players:GetChildren()) do

				if admin.Name == plr.Name then

					table.remove(player_table, pos)

				end

			end

		end

	else

		local player = game.Players:FindFirstChild(person)

		if player then

			table.insert(player_table, player)

		else

			return false

		end

	end



	return player_table

end



local function valid_value(action, value)

	for _,command in pairs(needValue) do

		if command == action then

			if not value then

				return false

			end

		end

	end



	return true

end



--takes command and splits it up

local function get_command()

	local command = {}

	for word in string.gmatch(box."%S+") do

		table.insert(command, word)

	end

	local action = command[1]

	local person = command[2]

	local value = command[3]



	box.Text = ''



	if valid_command(action)then

		local player_table = valid_player(person)

		if player_table then

			if valid_value(action, value) then

				commandEvent:FireServer(action, player_table, value)

			else

				box.Text = 'Value Error'

			end

		else

			box.Text = 'Invalid Player'

		end

	else

		box.Text = 'Invalid Command'

	end



end



kill.MouseButton1Click:Connect(function()
	rs.KillPlayer:FireServer(player.MpuseButton1Click)
end)

Appear+Disappear:Just a script to make ‘Toggle’ and ‘Off’ options for GUI
Kill Script:The thing we just talked about
PlayerListHandler:The script for the frame that we just did the Change colour thing

The TargetPlayerChoices with the options in it are the ones below the ‘Coming Soon…’ button.
The ‘Noob’ button is just at the bottom of the Scrolling Frame

There’s another script in SSS(ServerScriptService) called:Admin
and here’s the script

local rs = game:GetService('ReplicatedStorage')

local commandEvent = rs:WaitForChild('CommandEvent')



--kill player function

local function kill_player(player)

	player.Character.Humanoid.Health = 0

end



--freeze player function

local function freeze_player(player)

	player.Character.Humanoid.WalkSpeed = 0

	player.Character.Humanoid.JumpPower = 0

end



--unfreeze player function

local function unfreeze_player(player)

	player.Character.Humanoid.WalkSpeed = 16

	player.Character.Humanoid.JumpPower = 50

end



--hide player

local function hide_player(player)

	for _, limb in pairs(player.Character:GetChildren()) do

		if limb:IsA('BasePart') then

			limb.Transparency = 1

			if limb.Name == 'Head' then

				limb.face.Transparency = 1

			end

		elseif limb:IsA('Accessory') then

			limb.Handle.Transparency = 1

		end

	end

end



--show player

local function show_player(player)

	for _, limb in pairs(player.Character:GetChildren()) do

		if limb:IsA('BasePart') and limb.Name ~= 'HumanoidRootPart' then

			limb.Transparency = 0

			if limb.Name == 'Head' then

				limb.face.Transparency = 0

			end

		elseif limb:IsA('Accessory') then

			limb.Handle.Transparency = 0

		end

	end

end



--assign player speed

local function speed(player, value)

	player.Character.Humanoid.WalkSpeed = value

end



--assign player jump

local function jump(player, value)

	player.Character.Humanoid.JumpPower = value

end



--player trail

local function trail(player)

	local trail = player.Character:FindFirstChild('Trail')

	if not trail then

		local newTrail = Instance.new('Trail')

		newTrail.Parent = player.Character

		newTrail.Attachment0 = player.Character.HumanoidRootPart.RootRigAttachment

		newTrail.Attachment1 = player.Character.Head.NeckRigAttachment

		newTrail.Color = ColorSequence.new(Color3.fromRGB(255, 0, 255), Color3.fromRGB(0,255,0))

	else

		trail:Destroy()

	end

end



local function goto(admin, player)

	admin.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame

end



local function find(admin, player)

	player.Character.HumanoidRootPart.CFrame = admin.Character.HumanoidRootPart.CFrame

end



--Main Function

local function do_command(admin, action, player_table, value)



	for _, player in pairs(player_table) do

		if action == 'Kill' then

			kill_player(player)

		elseif action == 'Freeze' then

			freeze_player(player)

		elseif action == 'Unfreeze' then

			unfreeze_player(player)

		elseif action == 'Hide' then

			hide_player(player)

		elseif action == 'Show' then

			show_player(player)

		elseif action == 'Speed' then

			speed(player, value)

		elseif action == 'Jump' then

			jump(player, value)

		elseif action == 'Trail' then

			trail(player)

		elseif action == 'TPto' then

			goto(admin, player)

		elseif action == 'TPhere' then

			find(admin, player)

		end

	end



end

commandEvent.OnServerEvent:Connect(do_command)

This is what i made, set the client side in your current localscript and the client side in the current server script (if u want u can replace all)

-- CLIENT SCRIPT:
local rs = game:GetService("ReplicatedStorage")
local commandEvent = rs:WaitForChild('CmdsPipe')
local target = ""
local cmds = script.Parent:WaitForChild("Commands")
local list = cmds:WaitForChild("List")
local value = cmds:WaitForChild("Value")
local allowedButtons = {
	"Me", "All", "Noobs", "Freeze", "Hide", "Jump", "Kill", "Show", "Speed", "TPme", "TPelse", "Trail", "Unfreeze"
}
	
for _, v in pairs(list:GetDescendants()) do
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()
			target = v.Name
			
			local selectionColor = Color3.fromRGB(255, 0, 0) --pick the color you want
			local defaultColor = Color3.fromRGB(255, 255, 255) --pick the current color

			for _, i in pairs(list:GetDescendants()) do
				i.BackgroundColor3 = defaultColor
			end

			v.BackgroundColor3 = selectionColor
		end)
	end
end

for _, v in pairs(cmds:GetChildren()) do
	if v:IsA("TextButton") and table.find(allowedButtons, v.Name) then
		v.MouseButton1Click:Connect(function()
			if target ~= "" then
				local response = commandEvent:InvokeServer(v.Text, target, value.Text)
				if response then
					print("executed")
				end
			end
		end)
	end
end

-- SERVER SCRIPT:

local rs = game:GetService("ReplicatedStorage")
local commandEvent = rs:FindFirstChild('CmdsPipe') or Instance.new("RemoteFunction", rs) commandEvent.Name = 'CmdsPipe'

commandEvent.OnServerInvoke = function(player, command, target, value)
	if target then
		if target == 'me' then
			target = {player}
		elseif target == 'all' then
			target = game.Players:GetChildren()
		elseif target == 'noobs' then
			target = game.Players:GetChildren()
			for _, admin in pairs(game.ReplicatedStorage.Admins:GetChildren()) do
				for pos, plr in pairs(game.Players:GetChildren()) do
					if admin.Name == plr.Name then
						table.remove(target, pos)
					end
				end
			end
		else
			local Tplayer = game.Players:FindFirstChild(target)
			if Tplayer then
				target = {Tplayer}
			else
				return false
			end
		end
	end

	if command then
		local cmd = command:lower()
		if cmd == "kill" then
			for _, v in pairs(target) do
				local char = v.Character
				if char then
					local hum = char:FindFirstChildOfClass("Humanoid")
					if hum then
						hum.Health = 0
					end
				end
			end
			return true
		elseif cmd == "freeze" then
			for _, v in pairs(target) do
				local char = v.Character
				if char then
					local hum = char:FindFirstChildOfClass("Humanoid")
					if hum then
						hum.WalkSpeed = 0
						hum.JumpPower = 0
					end
				end
			end
			return true
		elseif cmd == "unfreeze" then
			for _, v in pairs(target) do
				local char = v.Character
				if char then
					local hum = char:FindFirstChildOfClass("Humanoid")
					if hum then
						hum.WalkSpeed = 16
						hum.JumpPower = 50
					end
				end
			end
			return true
		elseif cmd == "hide" then
			for _, v in pairs(target) do
				local char = v.Character
				if char then
					for _, limb in pairs(char:GetChildren()) do
						if limb:IsA('BasePart') then
							limb.Transparency = 1
							if limb.Name == 'Head' then
								limb.face.Transparency = 1
							end
						elseif limb:IsA('Accessory') then
							limb.Handle.Transparency = 1
						end
					end
				end
			end
			return true
		elseif cmd == "show" then
			for _, v in pairs(target) do
				local char = v.Character
				if char then
					for _, limb in pairs(char:GetChildren()) do
						if limb:IsA('BasePart') and limb.Name ~= 'HumanoidRootPart' then
							limb.Transparency = 0
							if limb.Name == 'Head' then
								limb.face.Transparency = 0
							end
						elseif limb:IsA('Accessory') then
							limb.Handle.Transparency = 0
						end
					end
				end
			end
			return true
		elseif cmd == "speed" then
			local val = tonumber(value)
			if val then
				for _, v in pairs(target) do
					local char = v.Character
					if char then
						local hum = char:FindFirstChildOfClass("Humanoid")
						if hum then
							hum.WalkSpeed = val
						end
					end
				end
			end
			return true
		elseif cmd == "jump" then
			local val = tonumber(value)
			if val then
				for _, v in pairs(target) do
					local char = v.Character
					if char then
						local hum = char:FindFirstChildOfClass("Humanoid")
						if hum then
							hum.JumpPower = val
						end
					end
				end
			end
			return true
		elseif cmd == "trail" then
			for _, v in pairs(target) do
				local char = v.Character
				if char then
					local trail = char:FindFirstChild('Trail')
					if not trail then
						local newTrail = Instance.new('Trail')
						newTrail.Parent = char
						newTrail.Attachment0 = char.HumanoidRootPart.RootRigAttachment
						newTrail.Attachment1 = char.Head.NeckRigAttachment
						newTrail.Color = ColorSequence.new(Color3.fromRGB(255, 0, 255), Color3.fromRGB(0,255,0))
					else
						trail:Destroy()
					end
				end
			end
			return true
		elseif cmd == "tpelse" then
			for _, v in pairs(target) do
				local adminChar = player.Character
				local char = v.Character
				if char and adminChar then
					adminChar.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame
				end
			end
			return true
		elseif cmd == "tpme" then
			for _, v in pairs(target) do
				local adminChar = player.Character
				local char = v.Character
				if char and adminChar then
					char.HumanoidRootPart.CFrame = adminChar.HumanoidRootPart.CFrame
				end
			end
			return true
		else
			return false
		end
	end
end

if i dont reply soon, im away

do i replace them all or what?
Its not working

well, im back

sorry, I wrote it quickly … it may contain errors, do you see any error in the console?

Basically:

  1. Add a RemoteEvent in ReplicatedStorage and rename it to “AddPlayer”

Script in ServerScriptService

game.Players.PlayerAdded:Connect(function(player)
    game.ReplicatedStorage.AddPlayer:FireAllClients(player.Name)
end)

LocalScript in ServerStorage (Rename it to ControlScript)

script.Parent.MouseButton1Click:Connect(function()
	local textBox = --variable of your text box
		
	textBox.Text = script.Parent.Text
end)

LocalScript in the Frame of the players list

game.ReplicatedStorage.AddPlayer.OnClientEvent:Connect(function(playerName)
    local ControlScript = game.ServerStorage.ControlScript

    local newButton = Instance.new("TextButton", script.Parent.Parent)
    newButton.Text = playerName
    ControlScript.Parent = newButton
end)

So the first script will send the name of the player that joins the game and fire it to the script inside the frame list, that script will generate a new textbutton to add to the list with the name of the player and clones a localscript that when the button is pressed set the name of the player in the textbox.

You can make a button that when pressed gets the name of the player from the textbox and does what the command has to do.

PlayerAdded can be used form the client too,
but he already have the player list loader…

also why put the controller in the button when you can set up the MouseButton1Click event on the script where you create the button by doing newButton.MouseButton1Click

he just needs to set the buttons to communicate with the server and execute the code.

Oh ok im sorry really i didn’t read all, that was so long, anyways he can use a RemoteEvent to send the things to the server.

By the way, I don’t know what items are contained in “Admin”, but make sure you have them
image

if you see any error in the console tell me so ill fix

at the client side,
the last end for the script had an error
Expected ‘end’ to close ‘do’ at line 112,get did you forget to close ‘then’ at line 117?

Edit:Fixed this but still doesn’t work