How to run HD Admin Commands From The Server

I have an admin gui and when you press a button it sends a command to the server using a remote event. This command can be for example /fly, I want to make it that the server runs that command through HD Admin.

This code sends the command when the button is pressed:

local cmdent = game:GetService("ReplicatedStorage"):WaitForChild("CommandEvent")

script.Parent.MouseButton1Down:Connect(function()
	cmdent:FireServer("/fly")
end)

Then the server receives it:

cmdent.OnServerEvent:Connect(function(plr, cmd)
	if allowedUserIds[plr.UserId] then
		plr = tostring(plr)
		-- Command here, im guessing it should be smth like hdadmincmd(plr, cmd)
	end
end)
1 Like

make a bindable event/ModuleScript that returns closure to manipulate stuff.

I got it :fire: here:
Client:

local cmdent = game:GetService("ReplicatedStorage"):WaitForChild("CommandEvent")

script.Parent.MouseButton1Down:Connect(function()
	cmdent:FireServer("fly all")
end)

Server:

local sstore = game:GetService("ServerStorage")
local HDServer = sstore:WaitForChild("HDAdminHDServer")
local HDAdmin = require(HDServer:WaitForChild("Modules"):WaitForChild("Parser"))
local STARTUP_TIME = 3
local GameTime = workspace.DistributedGameTime
if GameTime < STARTUP_TIME then
	task.wait(STARTUP_TIME - GameTime)
end
if #plrs:GetPlayers() == 0 then
	plrs.PlayerAdded:Wait()
end
local Main = _G.HDAdminMain
local PD = Main.pd

cmdent.OnServerEvent:Connect(function(plr, cmd)
	pfx = PD[plr].Prefix
	HDAdmin.ParseMessage(plr, plr, pfx .. cmd)
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.