How to make a Gamepass | Roblox Studio | Scripting Tutorial

Опубликовано: 16 Июль 2026
на канале: Slydonut6414
539
25

Server Side Script -
local MarketPlaceService = game:GetService("MarketplaceService")
local gamePassId = 00000000 -- Gamepass ID here

game.Players.PlayerAdded:Connect(function(player)
local ownsPass = Instance.new("BoolValue", player)
ownsPass.Name = "OwnsPass"
ownsPass.Value = false

local hasPass

hasPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamePassId)

if hasPass == true then
ownsPass.Value = true
-- Insert the code for what the game should do
-- The code here will execute if player owns this gamepass
end

end)

MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player, purchasedPassID, purchaseSuccess)
if purchaseSuccess == true and purchasedPassID == gamePassId then
player.OwnsPass.Value = true
-- Insert the code for what the game should do
-- Paste the code you entered in the previous function over here
-- The code here will execute when the player buys the gamepass
end
end)

Client Side Script -
local MarketPlaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local gamePassId = 00000000 -- Gamepass ID here
local button = script.Parent
local ownsPass = game.Players.LocalPlayer:WaitForChild("OwnsPass")

button.MouseButton1Click:Connect(function()
local hasPass = false

hasPass = MarketPlaceService:UserOwnsGamePassAsync(player.UserId, gamePassId)

if hasPass == true or ownsPass.Value == true then
button.Text = "You already own this pass"
wait(2)
button.Text = "Buy Gamepass"
else
MarketPlaceService:PromptGamePassPurchase(player, gamePassId)

end

end)
-----------------------------------------------------
Music:
Biscuit - Lukrembo
   • lukrembo - biscuit  

Chocolate - Lukrembo
   • lukrembo - chocolate  

Together - Lukrembo
   • lukrembo - together  

I always love you - Lukrembo
   • lukrembo - i always love you  

---------------------------------------------------

Social media -
Twitter -   / slydonut6414  
Instagram -   / slydonut6414  

Subscribe!!! -    / @slydonut6414  

#roblox #robloxstudio #scripting #gamepass