Gamepass shop system [trello help]

This is my script for my game, I want to create a trello board for a database. I want the format to be:

USERNAME:USERID

Each list will be named “(toolname) Database” and I want it to give the player a permanent tool instead of them buying the gamepass, etc. This can be used for some reasons like an error in the system, new accounts etc. I do not know how so If you can help me edit the script I can bind it and we can go through errors.

local button = script.Parent

local tool = game.ServerStorage.ToolName – Replace ToolName with the name of your tool in ServerStorage

local gamePassId = script.Parent.GamepassId

– Function to give the tool to the player

local function giveTool(player)

local toolClone = tool:Clone()

toolClone.Parent = player.Backpack

end

– Check if player owns the gamepass when they join the game

game.Players.PlayerAdded:Connect(function(player)

if game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(player.UserId, gamePassId.Value) then

giveTool(player)

end

end)

– Check if player owns the gamepass when the game starts

for _, player in ipairs(game.Players:GetPlayers()) do

if game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(player.UserId, gamePassId.Value) then

giveTool(player)

end

end

– Check if player owns the gamepass when they respawn or die

game.Players.PlayerAdded:Connect(function(player)

player.CharacterAdded:Connect(function(character)

if game:GetService(“MarketplaceService”):UserOwnsGamePassAsync(player.UserId, gamePassId.Value) then

giveTool(player)

end

end)

end)

Property of Rapid_Gaming22

I don’t think using Trello is the best (or even practical) approach for this problem. Instead, just save a bool value using DataStore that is set to true when they purchase the gamepass. If you need to manually give the player a gamepass for any reason you can set that value to true.

1 Like

Trello is definitely not your best option here; think about this:

If your game was to get a ton of exposure, you’d have to manually do stuff with that data. It’s also not easily scalable.

With Roblox datastores, they scale with your game. More players = more data you can store. Using Roblox datastores are your best option. Use the API docs for more help on datastores.

1 Like

Trello is for planning stuff, not for datastores, Roblox has DataStoreService and read the docs about the service, and please put three backticks like this for the code

```lua
-- this is a test
```

How would I then give it to someone like an F9 command, can you tell me more and what would I do to the script?

local DataStoreService = game:GetService("DataStoreService")
local gamePassOwnershipDataStore = DataStoreService:GetDataStore("GamePassOwnership")

local button = script.Parent
local player = game.Players.LocalPlayer
local gamePassId = script.Parent.GamepassId
local tool = game.ServerStorage.Tool -- change this to the name of your tool in ServerStorage

local function giveTool()
	-- Give the player the tool
	local backpack = player.Backpack
	local toolClone = tool:Clone()
	toolClone.Parent = backpack
end

local function checkOwnership()
	-- Check if the player owns the game pass
	local success, isOwned = pcall(function()
		return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, gamePassId.Value)
	end)

	if success and isOwned then
		-- Check if the player has already been granted the tool permanently
		local success, hasPermanentOwnership = pcall(function()
			return gamePassOwnershipDataStore:GetAsync(player.UserId .. "_" .. gamePassId.Value)
		end)

		if success and hasPermanentOwnership then
			-- Give the player the tool since they already have permanent ownership
			giveTool()
		else
			-- Give the player the tool and grant them permanent ownership
			giveTool()
			pcall(function()
				gamePassOwnershipDataStore:SetAsync(player.UserId .. "_" .. gamePassId.Value, true)
			end)
		end
	end
end

checkOwnership()

game.Players.PlayerAdded:Connect(function(newPlayer)
	if newPlayer == player then
		checkOwnership()
	end
end)

Property of @Rapid_Gaming22 .

How would I make it so if I run an F9 Command (userid) on a player (player it being executed on is not ingame) they will get the permanent tool.