Hi!
So, I have been trying to create a resetData command that would obliterate the specified person’s data.
The only problem is I get an error: Error occurred while evaluating command string "resetData smartabity1" tables cannot be cyclic ReplicatedStorage.CmdrClient.Shared.Dispatcher:81 ReplicatedStorage.CmdrClient.Commands.resetData:23
I tried debugging to see what the issue was by putting a print right under the function before it checks if you are admin or not, then I put another print under that.
The first print is running but the second isn’t so I suspect it is the admin system not functioning.
I use a datastore to check if the person is admin or not.
I place all that in a remote function on the server (pretty obvious lol).
Then I declare a variable isAdmin to equal the directory of which the remote function is located and invoke it.
then I run an if statement saying if the remote function comes back true, invoke another server which will reset the players data. however if they aren’t admin, it will return “u arent admin!!!111” and log the command with another remote function I setup.
FYI, the command is ran on the client, thats why there are so many remote functions.
don’t ask me to run it on server, I tried running it on client before I lost all my data and it worked.
Sorry if this is totally unnecessary I just decided to explain all of my code incase people don’t understand stuff.
This is all my code:
Main Command:
local Players=game:GetService("Players")
return {
Name = "resetData",
Aliases = {"playerData"},
Description = "Specified Player's data will be obliterated.",
Group = "Moderator",
Args = {
{
Type = "player",
Name = "victim",
Description = "The victim about to witness their own data go woosh."
}
},
Run = function(context,player)
print'lol'
print(context)
local isAdmin = game.ReplicatedStorage.eventcontainer.isAdmin:InvokeServer(context)
if isAdmin == true then
print'is admin!!!'
game.ReplicatedStorage.modgear.ClearPlayerData:InvokeServer(player)
return "Success! Smashed their data at our facility!"
else
game.ReplicatedStorage.eventcontainer.CmdrLogging:InvokeServer(context,"resetData")
return "You do not have permission to use this command!"
end
end,
}
isAdmin remote function :
local CoreDS = DataStore:GetDataStore(contexxt.UserId.."Core")
local ModBool = CoreDS:GetAsync("Admin")
if ModBool then
return true
else
return false
end
end
A cyclic table, if for some reason you didn’t look it up already, is a table that contains itself.
local a = {}
a[1] = a --> Error: Tables cannot be cyclic
Line 23 isn’t adding anything to a table that would cause that though. I could just be blind, but I don’t see anywhere in the code you gave that could cause a table error.
Just for the record, invoking or firing the server in RemoteEvents and RemoteFunctions automatically supplies the player as the first argument. I doubt that’s your problem though, but it will potentially cause a problem when you use CmdrLogging function.
I don’t see what the problem is in the small amount of code we have here.
Not really, we work for free. People help with stuff where they have the information they need from you and some knowledge of the problem. Clearly a table is in use somewhere (DataStores can qualify for this problem too) but I don’t see you adding keys or setting data stores in any of the code here. I’m quite confident that these scripts aren’t the problem.
Don’t really want to go learn a framework, thank you though.
But it looks like that’s the only table in the code you posted that could be causing the cyclical error. Double-check that you’re creating and using it correctly.
You could print that out, or use the Lua debugger and step through the code line-by-line to see if the variables are what you expect.
You might have more luck asking in the Cmdr discord—there’s a link in the docs you linked. I’m getting the sense that this might be a pretty framework-specific question. Good luck!