Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make this private module with a Number Value?

Can someone help me with private modules?

I have this script right here:

local wat = 678054912
local market = game:GetService("MarketplaceService")


game.Players.PlayerAdded:Connect (function()

script.Parent=game.ServerScriptService
local market=game:GetService("MarketplaceService")
for i,v in pairs(game.Players:GetChildren()) do
    if not market:PlayerOwnsAsset(v,wat) then
        market:PromptPurchase(v,wat)
    end
  end
end)

But I want it to be a private module where the user only needs to do this:

local PRODUCT_ID = 678054912
require((2985042) (PRODUCT_ID)

I have done this with the MainModule:

local module = function(PRODUCT_ID)
    
    local Product = Instance.new("NumberValue")
    Product.Name = "GamepassProduct"
    Product.Value = PRODUCT_ID
    Product.Parent = game.ServerScriptService
    
    script.Popup.Parent = game.ServerScriptService
    
end

The main script of the popup that I put in the MainModel:

local wat = GamepassProduct.Value
local market = game:GetService("MarketplaceService")


game.Players.PlayerAdded:Connect (function()

script.Parent=game.ServerScriptService
local market=game:GetService("MarketplaceService")
for i,v in pairs(game.Players:GetChildren()) do
    if not market:PlayerOwnsAsset(v,wat) then
        market:PromptPurchase(v,wat)
    end
  end
end)

Someone help i've been on this for a couple hours.

Also the main script makes it so whenever a player joins the server, it will auto popup an item.

1 answer

Hi If you want it so whenever someone joins a server it prompts a purchase See below:

Loader Script:

ProductId = IDHERE
module = require(PUT_YOUR_ID_HERE)
module.ProductID(ProductId)

MainModule:

local module = {}

function module.ReturnTheThing(argument)
local market = game:GetService("MarketplaceService")


game.Players.PlayerAdded:Connect (function()

script.Parent=game.ServerScriptService
local market=game:GetService("MarketplaceService")
for i,v in pairs(game.Players:GetChildren()) do
    if not market:PlayerOwnsAsset(v,argument) then
        market:PromptPurchase(v,argument)
    end
  end
end)
end

return module

1 comment

0

Didn't work.

This discussion is preserved as it was. New answers, comments, and votes are closed.