So in this admin gui I am making it to where when you type a code it executes it when pressing the "execute" button. Problem with this is it is firing the event but not executing the code. I have no idea why and I am baffled. Could someone please help?
local script
---Player thingy
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local char = player.Character
local mouse = player:GetMouse()
---Services
local uis = game:GetService("UserInputService")
--- Guis
local screen = script.Parent
local Cmd = screen.CmdBox
local execute = screen.Run
local maingui = screen.Gui
local mainframe = maingui.Frame
local history = mainframe.ChatHistory
local list = mainframe.AdminList
local Cmds = mainframe.Commands
local history1 = mainframe.ChatHistory1
local list1 = mainframe.AdminList1
local Cmds1 = mainframe.Commands1
local expla = mainframe.Explanation
--Event
local event = screen:WaitForChild("Event")
list1.MouseButton1Down:connect(function()
list.Active = true
list.Visible = true
Cmds.Active = false
Cmds.Visible = false
history.Active = false
history.Visible = false
end)
history1.MouseButton1Down:connect(function()
list.Active = false
list.Visible = false
Cmds.Active = false
Cmds.Visible = false
history.Active = true
history.Visible = true
end)
Cmds1.MouseButton1Down:connect(function()
list.Active = false
list.Visible = false
Cmds.Active = true
Cmds.Visible = true
history.Active = false
history.Visible = false
end)
execute.MouseButton1Down:connect(function()
Cmd.Text = ("Enter command")
if Cmd.Text ~= nil then
event:FireServer(Cmd.Text)
end
end)
Server script
---Player thingy
local player = script.Parent.Parent.Parent
repeat wait() until player.Character
local char = player.Character
---Services
--- Guis
local screen = script.Parent
local Cmd = screen.CmdBox
local execute = screen.Run
local maingui = screen.Gui
local mainframe = maingui.Frame
local history = mainframe.ChatHistory
local list = mainframe.AdminList
local Cmds = mainframe.Commands
local history1 = mainframe.ChatHistory1
local list1 = mainframe.AdminList1
local Cmds1 = mainframe.Commands1
local expla = mainframe.Explanation
--Event
local event = screen:WaitForChild("Event")
--- Admins
local admins = {["Player1"] = true, ["Player"] = true, ["yougottols1"] = true, ["Cyber_Monkey"] = true}
event.OnServerEvent:connect(function(plyr, Trying)
print("Fired")
function player(name)
print("Working")
for i,v in pairs(game.Players:GetChildren()) do
if v.Name:lower() == name:lower() then
print("better")
return v
end
end
if string.sub(string.lower(Trying), 1,5) == "kill/" then
local player = game.Players:GetPlayers()(string.sub(Trying, 6),plyr)
if player ~= 0 then
for i = 1, #player do
if player[i].Character ~= nil then
local human = player[i].Character:FindFirstChild("Humanoid")
if human ~= nil then
human.Health = 0
end
end
end
end
end
end
end)

1 comment
Fix your indentation. If you did that, you would realize that in the .OnServerEvent connection, you create a function, but you don't close it until the end of the connection, so you never call the function. That's why none of it is being executed.