This is an issue I’ve had from the start and have no clue how to fix:
Summary: I have admin. If admin runon setting is on the client, it sends it to the client with a remote function. the client, receives the arguements, and the function itself. But when I print the function, I should get something like function: 30dxcgr3r9fd84
but i get nil. I don’t want to make the commands available to the client because then people would steal it. I’ve been able to get it to work sometimes, which leads me to believe I’m doing something wrong. But unsure.
This is the command within the module script
Info.Commands.View = {
["command"] = ":view",
["ranon"] = "client",
["arguements"] = 2,
["requirement"] = 1,
["execute"] = function(player, PlayerToView)
local StopLoop = false
local Camera = workspace.CurrentCamera
local success, errormsg = pcall(function()
for i,v in pairs(game.Players:GetPlayers()) do
if StopLoop == false then
if string.match(string.lower(v.Name), string.lower(PlayerToView)) then
StopLoop = true
local PlayerToView = v.Character
Camera.CameraSubject = PlayerToView.Humanoid
Camera.CameraType = "Custom"
Camera.CFrame = PlayerToView.Head.CFrame
end
end
end
end)
print(success, errormsg)
if success and StopLoop then
return "Executed"
elseif not StopLoop then
return "PlayerNotFound"
elseif errormsg then
return {"Error", errormsg}
else
return "Fail"
end
end
}
Server Sided Execution
local function HandleExecution(plr, Ranon,Execute,A)
local ChatArguements = A
table.remove(ChatArguements, 1)
local FunctionResult
if Ranon == "server" then
FunctionResult = Execute(plr, table.unpack(ChatArguements))
elseif Ranon == "client" then
FunctionResult = ClientExecution:InvokeClient(plr, Execute, ChatArguements)
else
print('error in execution, nor server nor client')
end
for i,v in pairs(CommandResponses) do
if i == FunctionResult or i == FunctionResult[1] then
print(i,v,FunctionResult)
if v.Type == "Success" then
ErrorSuccessCommunicate:InvokeClient(plr,"Success", nil)
elseif i == "Error" then
ErrorSuccessCommunicate:InvokeClient(plr, "Error", FunctionResult[2])
else
ErrorSuccessCommunicate:InvokeClient(plr, "Error", v.Message)
end
end
end
end
Client Side Execution
RepStor.AdminEvents.ClientExecution.OnClientInvoke = function(executeFunction, args)
print(executeFunction,args)
if not args then
args = {}
end
local Result = executeFunction(game.Players.LocalPlayer, table.unpack(args))
return Result
end
Picture of printing functions and arguements:
Client sided error image:
I assume it has something to do with the nil print because I have a print outside of the pcall in the command, and it’s not printing at all.
Any help is greatly appreciated.