Making A Rank Command problem

So, I am making a rank command, invoke a remote function with the person promoting, the person that will be promoted, a useless argument, and finally the rank chosen.

I set an if statement to detect if anything was nil.
If it was, it would ban the promoter.

however, whenever I run the remote function, it seems to think regardless if it is nil or not, its banning me.
im not sure why, i tried printing the values of the rank and the useless argument and it returned without nil.

game.ReplicatedStorage.eventcontainer.promoteFunction.OnServerInvoke = function(promoter,member,useless,rank)
	local datastore = game:GetService("DataStoreService")
	local Storage = datastore:GetDataStore(member.UserId.."Core")
	local userId = promoter.UserId
	local memUserId = member.UserId
	local Players = game:GetService("Players")
	local thumbType = Enum.ThumbnailType.HeadShot
	local thumbSize = Enum.ThumbnailSize.Size420x420
	local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
	local contentp, poo = Players:GetUserThumbnailAsync(memUserId, thumbType, thumbSize)
	print(rank)
	print(useless)
	if useless or rank == nil then
		local datastorep = game:GetService("DataStoreService")
		local Storagep = datastorep:GetDataStore(promoter.UserId.."Core")
		Storagep:SetAsync("isBanned", true)
		Storagep:SetAsync("Reason", "Exploiting: mod remote event");
		Storagep:SetAsync("Moderator","Advanced Combat Safety Department")
		Storagep:SetAsync("Date",os.date("*t", os.time()))

		member:Kick("Hack on a lego game? You gotta be serious. \nYou have been banned from Advanced Combat. \nReason: Anti Cheat: Exploiting into remote events")
		local url = ""
		local http = game:GetService("HttpService")

		local data = {
			embeds = {
				{
					author = {name = "Advanced Combat Security"},
					title = "Banned "..promoter.Name .." Indefinitely",
					type = "rich",
					description = "Exploiting | RE/RF nil",
				}
			}
		}

		local newdata = http:JSONEncode(data)
		http:PostAsync(url,newdata)
		return
end
end

this is the code that u are definitely needing, not all of it.

1 Like

try doing:

if useless == nil or rank == nil then

2 Likes

u saved my life man,
i realized it checks if useless is true or if rank is nil
lemme test it

haha no worries! we all get tripped up by small issues like these. sometimes it just takes a fresh set of eyes!

2 Likes

Yo btw, remove the webhook link from your post (unless it’s fake)

2 Likes

thank you, i didnt notice the webhook on there haha

hm interesting.
it looks like ur solution would work but it seems like http is forbidden?
does the game settings work for you in studio?
figured out i get the sign out all other sessions a couple minutes ago incase my account got hacked
guess it applies to roblox studio too.

1 Like

try testing in the roblox app. if that doesn’t work, try resetting/redoing your webhook.

also, make sure not to share it with anyone :slight_smile:

2 Likes

works like a charm
i just wanted to compliment ur probably the nicest and most understanding developer ive ever witnessed :slight_smile:
keep it up !

1 Like

ik this is irrelevent but i got a question:
should I use updateasync or setasync for datastore ranks??

i’m glad! thank you! :slight_smile:

1 Like

Well, the only advantage of UpdateAsync is that it contains the old value. If you care about the old value, use Update. Otherwise, SetAsync works for you.

i dont really care about the old value, its not like im gonna need a ;restorerank command.
if the person had a mistake ranking someone just do the command again

1 Like