Can debug library used on servers?

If debug library can be used on servers, is it possible to check if it was fired by a injector/exploit application? This would only apply to remote events and functions an example would be:

local format = {
	{"Players", "Player_Name", "PlayerScripts", 1},
	{"ReplicatedStorage", "Signal", 2}
}

local function checkStackDifference(stackBegin : string)
	for index = 1, #stackBegin - 1 do
		local stack = stackBegin[i]:split(".")

		for index, name in ipairs(stack) do
			if (format[index] == "Player_Name") then
				if (not (name == PlayerObject.Name)) then
					return false
				end
			elseif (index == #stack and not (format[index] == tonumber(name))) then
				return false
			elseif (not (format[index] == name)) then
				return false
			end
		end
	end

	return true
end

Event.OnServerEvent:Connect(function(player, argument)
	local stackBegin = debug.traceback():gsub(":", "."):split("\n")
		
	if (not checkStackDifference(stackBegin)) then
		player:Kick("...")
	end
end)

I’m not sure if this works never tried it.

https://developer.roblox.com/en-us/api-reference/lua-docs/debug

The format of the returned traceback is not defined and may change at any time; use only for debug diagnostics and error analytics. It’s recommended that you never parse the return value of this function for specific information, such as script names or line numbers.

1 Like