Need help with Replacing Old Typing Admin System to Buttons

So I’m trying to redesign my old animal panel to a new one (from typing to just pressing buttons)

And I messed up will turning my scripts,here’s one of the scripts I messed up with
To make it clear:
Old system : /kill all
New system: – Need help with
*clicks All – Need Help with
then
*clicks Kill

local function choice(target)
	local target = players:FindFirstChild(targetName)
end


--make sure player exists

local function valid_player(person)

	local player_table = {}
	
		me.MouseButton1Click:choice(target)

		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
2 Likes

how?
and btw if you don’t mind can you edit my script instead lol its hard for me to scribble :sweat_smile:

local function choice(target)
	local target = players:FindFirstChild(targetName)
end


--make sure player exists

local function valid_player(person)

	local player_table = {}
	
	       me.MouseButton1Click:Connect(choice(target)

		local player = game.Players.LocalPlayer

		table.insert(player_table, player)

	elseif person == 'all' then

	table.insert(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, plr)

				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

I basically want to change table.insert to buttons.
Like ‘button.MouseButton1Click’
But idk how to fix to whole script to work with it

button.MouseButton1Click:Connect(function()
    table.insert(tableName, objectToInsert)
end)

This adds an object to a table.

Here’s the entire script
Local script:

local rs = game:GetService('ReplicatedStorage')
local players = game:GetService("Players")
local commandEvent = rs:WaitForChild('CommandEvent')

local frame = script.Parent.Commands

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

local choose = frame.TargetPlayerChoices
local me = choose.Me
local all = choose.All
local noob = choose.Noobs

local box = frame.Output

local list = frame.List
local Buttons = frame.Buttons -- Buttons
local target = ""

local plrGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")

--list of valid commands

local actions = {



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

	'Trail', 'TPto', 'TPhere'



}



local needValue = {



	'Speed', 'Jump'



}


local function choice(target)
	local target = players:FindFirstChild(targetName)
end


--make sure player exists

local function valid_player(person)

	local player_table = {}
	
	       me.MouseButton1Click:Connect(choice(target)

		local player = game.Players.LocalPlayer

		table.insert(player_table, player)

	elseif person == 'all' then

	table.insert(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  = 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

enter.MouseButton1Click:Connect(get_command)

Server Script:

local rs = game:GetService('ReplicatedStorage')
local players = game:GetService("Players")
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)


Here’s every Button

wdym inside a table?
u mean the frame?

No i mean:

You have this table:

So you have to search the command inside this table

btw just asking,do you know the point of this topic is to change the script from old (typing in a box) to new (press buttons) for commands (there’s a picture below the topic,that might explain it)
Now saying you dunno,just asking.

so basically I have a set of old script(given above with a lot of info),
I want to edit the script so it works with the new system.
I think editing just the local script is ok since the admin script just fires the event with command effects

Yo I think the web’s down

hi?
are you there?
I kinda wanna get it done asap