How would I implement a database for whitelisting

Hi, I’m not really familliar with databases and datastores. And in a script, to prevent leaks, I want to add a whitelist system where I can grab user/group IDs so if the owner of the group/game isn’t on my whitelist, the script destroys.

So far I have this:

if game.CreatorType == Enum.CreatorType.Group then
			if game.CreatorID ~= -- id here then
script:Destroy()
end
		end
		```

Is there a way to grab this data from a database so I can add/remove users/groups?

What do you mean by "leaks? Other games cannot access the same Datastore.

Experiences can’t access other experience’s data stores. You could use HTTP requests to check but it requires a special permission that is disabled by default.

If someone who steals your game and has more experience at coding than a potato, they can just remove anti stealing code (scripts only run when the game is in play mode and scripts deleted while in play mode are recoverable). Your best approach to prevent game scripts being leaked is to be careful who you share the game with. You could also obfuscate your code, but be careful about that because Roblox may terminate your account for that.

TL;DR: just be careful who you give permissions in your game.

1 Like

This code supports: Player Names, Player IDs, and Checks if the Player is in a specific group with it’s ID.
If you want to use this, no need to credit! Even though credits, would be cool.
Here’s the script!

local Whitelist = {"M4ank", "Ey3r1sAlpha"} -- This is converted to UserIDS.
local WhitelistIDS = {2702968750, 1} -- This is just plain UserIDS.
local WhitelistGroupIDS = {3829, 1}
function DoSpecialPersonScript(Player)
	print(Player.Name)
	-- Put code here after somebody is special..?
end
game.Players.PlayerAdded:Connect(function(Player)
	for _,table in pairs(Whitelist) do
		local ID = game.Players:GetUserIdFromNameAsync(table)
		if Player.UserId == ID then
			DoSpecialPersonScript(Player)
		end
	end
	for _,ID in pairs(WhitelistIDS) do
		if Player.UserId == ID then
			DoSpecialPersonScript(Player)
		end
	end
	for _,ID in pairs(WhitelistGroupIDS) do
		if(Player:IsInGroup(ID)) then
			DoSpecialPersonScript(Player)
		end
	end
end)

No, as in. If I’m selling a script for let’s say a nametag, and I add a whitelist, how do I add the group/users ID to a third-party database, and grab the data there. So if they leak the product I sold them, I can remove their user.

I see, that isn’t really possible because they could always remove your script protection. Unfortunately, obfuscating your code wouldn’t work either because Roblox could delete your account, people might think your script is sketchy and it can still be deobfuscated. @m4ank’s answer wouldn’t work for what you want either.

A database is difficult, but not impossible. You couldn’t use DataStoreService or HttpService because DataStoreService isn’t shared across experiences and HttpService is disabled by default. Instead you could use a Roblox asset’s description for storing data. It would be read only from scripts, but that’s perfect for your use case.

What you’d need to do is designate a single asset which should not get content deleted for any reason. Then in the description, place all the allowed creator IDs (users and groups) in the
description of the asset. Like this:

287113233,2702968750,9697297

(those IDs are my user ID, your user ID and my group ID.) Don’t put a space between IDs, just a comma. In the example I’ve used this asset https://create.roblox.com/marketplace/asset/11389869265
Inside your script you can paste this code

local MarketplaceService = game:GetService("MarketplaceService")

local product = MarketplaceService:GetProductInfo(11389869265, Enum.InfoType.Asset)

local string_ids = string.split(product.Description, ",")

if not table.find(string_ids, tostring(game.CreatorId)) then
	print("fraud!")
end

Replace 11389869265 with your own asset ID. (though you can use it for testing the script initially)

Every time it is run, it’ll check if the game.CreatorId is in the description of your asset. If not it will print “fraud!”. This takes about 2 seconds.
A smaller, more obscurer version of that code is:

if not table.find(string.split(game.MarketplaceService:GetProductInfo(11389869265, 0).Description, ","), tostring(game.CreatorId)) then print("fraud!") end

Some things I suggest: instead of destroying the script, or printing anything, you should make the script silently not work, therefore people are more likely to dump your script than remove any anti theft components.

When you want to allow new people to use your script, just go to the Creator Dashboard and edit your asset’s description.

1 Like

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