Well I just gotta warn you before hand; this code is extremely messy as I implemented it into my game roughly four years ago haha. That said, making this post is a part of cleaning it up, so thats what I have been working through.
I have 2 scripts:
1 handles Gamepasses; here it is:
Summary
local MartketPlaceService = game:GetService("MarketplaceService")
local players = game:GetService("Players")
pcall(function()
game.Players.PlayerAdded:connect(function(player)
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId,1597840) then
local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name)
cashmoney.Value = cashmoney.Value + 10000
local msg = Instance.new("Hint",workspace)
player.CharacterAdded:connect(function(char)
game.Lighting.LaserCannon:Clone().Parent=player.StarterGear
if char:WaitForChild("Humanoid") then
char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 30
char.Humanoid.Health = char.Humanoid.Health + 30
char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + 10
game.Lighting.LaserCannon:Clone().Parent=player.Backpack
end
end)
msg.Text = player.Name.." joined the game as an Executive!"
wait(2)
msg:Destroy()
elseif MartketPlaceService:UserOwnsGamePassAsync(player.UserId,1597332) then
local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name)
cashmoney.Value = cashmoney.Value + 5000
player.CharacterAdded:connect(function(char)
if char:WaitForChild("Humanoid") then
char.Humanoid.MaxHealth = char.Humanoid.MaxHealth + 25
char.Humanoid.Health = char.Humanoid.Health + 25
char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + 5
game.Lighting.LaserCannon:Clone().Parent=player.Backpack
end
end)
local msg = Instance.new("Hint",workspace)
msg.Text = player.Name.." joined the game with Super VIP!"
wait(2)
msg:Destroy()
elseif MartketPlaceService:UserOwnsGamePassAsync(player.UserId,1598126) then
local cashmoney = game.ServerStorage.MoneyStorage:WaitForChild(player.Name)
cashmoney.Value = cashmoney.Value + 500
local msg = Instance.new("Hint",workspace)
msg.Text = player.Name.." joined the game as a VIP!"
wait(2)
msg:Destroy()
end
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, 14390869) then
print("player owns music pass")
local gui = player.PlayerGui
gui.Radio.Main.CustomFrame.GamepassNeeded.Visible = false
end
print("GEAR GAME PASS GEAR GAME PASS GEAR GAME PASS")
gpid = 1616511 --Game Pass ID
tools = {"JetPack"} --Put VIP tools in Lighting, then put their exact names here.
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, gpid) then
print("Has One")
for i = 1,#tools do
game.Lighting:FindFirstChild(tools[i]):Clone().Parent = player.Backpack
end
else
print("No One")
end
two = 1616412 --Game Pass ID
twotools = {"GrappleHook"} --Put VIP tools in Lighting, then put their exact names here.
------ DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, two) then
print("Has two")
for i = 1,#twotools do
game.Lighting:FindFirstChild(twotools[i]):Clone().Parent = player.Backpack
end
else
print("No two")
end
three = 1616331 --Game Pass ID
threetools = {"BlackHoleBomb"} --Put VIP tools in Lighting, then put their exact names here.
------ DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, three) then
print("Has three")
for i = 1,#threetools do
game.Lighting:FindFirstChild(threetools[i]):Clone().Parent = player.Backpack
end
else
print("No three")
end
four = 1616008 --Game Pass ID
fourtools = {"SubspaceTripmine"} --Put VIP tools in Lighting, then put their exact names here.
------ DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, four) then
print("Has four")
for i = 1,#fourtools do
game.Lighting:FindFirstChild(fourtools[i]):Clone().Parent = player.Backpack
end
else
print("No four")
end
five = 1616462 --Game Pass ID
fivetools = {"ExponentialRocketLauncher"} --Put VIP tools in Lighting, then put their exact names here.
------ DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, five) then
print("Has five")
for i = 1,#fivetools do
game.Lighting:FindFirstChild(fivetools[i]):Clone().Parent = player.Backpack
end
else
print("No five")
end
-- Handles gear on respawn
print("GEAR GAME PASS GEAR GAME PASS GEAR GAME PASS")
gpid = 1616511 --Game Pass ID
tools = {"JetPack"} --Put VIP tools in Lighting, then put their exact names here.
function respawned(char)
player = game.Players:GetPlayerFromCharacter(char)
print("Respawned")
if char:FindFirstChild("Head") ~= nil then
print("It's a Player!")
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, gpid) then
print("Has One")
for i = 1,#tools do
game.Lighting:FindFirstChild(tools[i]):Clone().Parent = player.Backpack
end
else
print("No One")
end
end
end
player.CharacterAdded:Connect(respawned)
two = 1616412 --Game Pass ID
twotools = {"GrappleHook"} --Put VIP tools in Lighting, then put their exact names here.
------ DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
function respawned(char)
player = game.Players:GetPlayerFromCharacter(char)
print("Respawned")
if char:FindFirstChild("Head") ~= nil then
print("It's a Player!")
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, two) then
print("Has two")
for i = 1,#twotools do
game.Lighting:FindFirstChild(twotools[i]):Clone().Parent = player.Backpack
end
else
print("No two")
end
end
end
player.CharacterAdded:Connect(respawned)
three = 1616331 --Game Pass ID
threetools = {"BlackHoleBomb"} --Put VIP tools in Lighting, then put their exact names here.
------ DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
function respawned(char)
player = game.Players:GetPlayerFromCharacter(char)
print("Respawned")
if char:FindFirstChild("Head") ~= nil then
print("It's a Player!")
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, three) then
print("Has three")
for i = 1,#threetools do
game.Lighting:FindFirstChild(threetools[i]):Clone().Parent = player.Backpack
end
else
print("No three")
end
end
end
player.CharacterAdded:Connect(respawned)
four = 1616008 --Game Pass ID
fourtools = {"SubspaceTripmine"} --Put VIP tools in Lighting, then put their exact names here.
------ DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
function respawned(char)
player = game.Players:GetPlayerFromCharacter(char)
print("Respawned")
if char:FindFirstChild("Head") ~= nil then
print("It's a Player!")
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, four) then
print("Has four")
for i = 1,#fourtools do
game.Lighting:FindFirstChild(fourtools[i]):Clone().Parent = player.Backpack
end
else
print("No four")
end
end
end
player.CharacterAdded:Connect(respawned)
five = 1616462 --Game Pass ID
fivetools = {"ExponentialRocketLauncher"} --Put VIP tools in Lighting, then put their exact names here.
------ DON'T EDIT BELOW UNLESS YOU KNOW WHAT YOU'RE DOING
function respawned(char)
player = game.Players:GetPlayerFromCharacter(char)
print("Respawned")
if char:FindFirstChild("Head") ~= nil then
print("It's a Player!")
if MartketPlaceService:UserOwnsGamePassAsync(player.UserId, five) then
print("Has five")
for i = 1,#fivetools do
game.Lighting:FindFirstChild(fivetools[i]):Clone().Parent = player.Backpack
end
else
print("No five")
end
end
end
player.CharacterAdded:Connect(respawned)
end)
end)
2 handles Dev Products; here it is
Summary
local MarketplaceService = game:GetService("MarketplaceService")
local function processReceipt(receiptInfo)
local player = game:GetService("Players"):GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
return Enum.ProductPurchaseDecision.NotProcessedYet
end
print(player.Name.."just purchased".. receiptInfo.ProductId)
if receiptInfo.ProductId == 42820232 then
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + 5000
end
end
if receiptInfo.ProductId == 42820276 then
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + 10000
end
end
if receiptInfo.ProductId == 42820303 then
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + 25000
end
end
if receiptInfo.ProductId == 42820329 then
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + 100000
end
end
if receiptInfo.ProductId == 42820348 then
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + 500000
end
end
if receiptInfo.ProductId == 1145512229 then
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + 1000000
end
end
if receiptInfo.ProductId == 42870511 then
local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name)
if cashmoney then
cashmoney.Value = cashmoney.Value + 999999999
end
end
if receiptInfo.ProductId == 14390869 then
print("player bought music pass")
local gui = player.PlayerGui
gui.Radio.Main.CustomFrame.GamepassNeeded.Visible = false
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt
I am not sure if the codes are flawed to begin with since it is split in two scripts? As I said this was implemented 4 years ago and I am trying to clean it up, so please let me know what needs changed.