Hello, I have a module script that has the Button name and the gamepass ID. This is the template:
[“BUTTONNAME”] = GAMEPASSID;
local Mod = script.ModuleScript
require(Mod)
local Buttons = script.Parent:GetDescendants()
for i,Button in pairs (Buttons) do
if Button:IsA("ImageButton") then
Button.MouseButton1Click:Connect(function()
print("eh")
for BName,Id in pairs (Mod:GetDescendants()) do
print("yes")
if Button.Name == BName then
print("wow!")
game:GetService("MarketplaceService"):PromptPurchase(game.Players.LocalPlayer, Id)
end
end
end)
end
end
The first 2 lines are not correct since you don’t put the module in a variable. The Mod variable is just a reference to the ModuleScript, not the module itself. To fix it, you should replace the first two lines with:
local Mod = require(script.ModuleScript)
then adapt rest of the script to it.
Also next time, please provide the information about the problem, like @Nerkonl said.
require is not being used here correctly, a value from a ModuleScript is returned by a call to require, store that in a variable to make use of the ModuleScript’s contents