this is a dumb question to ask, just to clarify my mistake’s but I need to know how to make it so the gamepass works, or level requirement.
Client Code:
--//Main Var's
local player = game.Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local PlayerData = ReplicatedStorage:WaitForChild("PlayerData")
local PlayerFolder = PlayerData:WaitForChild(player.Name, math.huge)
local SelectedSlot = PlayerFolder:WaitForChild("SelectedSlot", math.huge)
local PlayerDataFolder = PlayerFolder:WaitForChild("Slot"..SelectedSlot.Value, math.huge)
local Level = PlayerDataFolder:WaitForChild("Level")
--//Gui System
local frame = script.Parent
local Remote = script.Pass
local Page1 = frame:WaitForChild("Page1")
local Page2 = frame:WaitForChild("Page2")
local PageBtn = frame:WaitForChild("PageButton")
local MagicPass = frame:WaitForChild("BuyPass")
local currentPage = 1
local skipLevelGamepassId = 1742991729
function updateStatLabels(page)
local buttonText = ""
if page == 1 then
Page1.Visible = true
Page2.Visible = false
if Level.Value >= 75 or hasSkipLevelGamepass(player) then
buttonText = "Turn Page >>"
PageBtn.Image.ImageColor3 = Color3.new(0, 1, 0)
else
buttonText = "LOCKED"
PageBtn.Image.ImageColor3 = Color3.new(1, 0, 0)
end
elseif page == 2 then
Page1.Visible = false
Page2.Visible = true
buttonText = "Prev Page <<"
PageBtn.Image.ImageColor3 = Color3.new(1, 0, 0)
end
PageBtn.Image.Label.Text = buttonText
end
function hasSkipLevelGamepass(player)
local success, hasPass = pcall(function()
return MarketplaceService:UserOwnsGamePassAsync(player.UserId, skipLevelGamepassId)
end)
return success and hasPass
end
PageBtn.MouseButton1Click:Connect(function()
if currentPage == 1 and (Level.Value >= 75 or hasSkipLevelGamepass(player)) then
currentPage = 2
elseif currentPage == 2 then
currentPage = 1
end
updateStatLabels(currentPage)
end)
MagicPass.MouseButton1Click:Connect(function()
MarketplaceService:PromptProductPurchase(player, skipLevelGamepassId)
end)
Level.Changed:Connect(function()
if Level.Value >= 75 or hasSkipLevelGamepass(player) then
updateStatLabels(currentPage)
end
end)
script.Pass.OnClientEvent:Connect(function(passName)
if passName == "BuyPass" or Level.Value <= 75 then
PageBtn.Image.Label.Text = "Turn Page >>"
PageBtn.Image.ImageColor3 = Color3.new(0, 1, 0)
print("Gamepass purchased on the client!")
end
updateStatLabels(currentPage)
end)
updateStatLabels(currentPage)
server side code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local skipLevelGamepassId = 1742991729
function processReceipt(receiptInfo)
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)
if player and receiptInfo.ProductId == skipLevelGamepassId then
print(player.Name .. " purchased the Gamepass!")
script.Parent:FireClient(player, "BuyPass")
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
MarketplaceService.ProcessReceipt = processReceipt