Roblox Studio'da bir LocalScript ile bir butona tıklandığında Roblox'un kendi Premium satın alma promptunu açmak için aşağıdaki adımları izleyebilirsiniz:
-
Butonunuzu Oluşturun:
- Öncelikle, ScreenGui içerisine bir TextButton veya ImageButton ekleyin. Bu buton, oyuncunun tıklayacağı buton olacak.
-
LocalScript Ekleme:
- Butonunuzun içine bir LocalScript ekleyin. Yani, butonun çocuğu olarak ekleyin.
-
LocalScript İçeriği:
- Aşağıdaki kodu LocalScript'inize ekleyin:
local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local button = script.Parent -- LocalScript'in parenti olan buton
button.MouseButton1Click:Connect(function()
MarketplaceService:PromptPremiumPurchase(player)
end)
Açıklama:
MarketplaceService: Roblox'ta oyun içi satın alma işlemleri için kullanılan bir hizmettir.
player: LocalScript içinde LocalPlayer referansı ile mevcut oyuncuyu alıyoruz.
button: Script'in parenti olan butonu referans alıyoruz.
MouseButton1Click: Butona tıklandığında tetiklenen bir olaydır.
PromptPremiumPurchase(player): Belirtilen oyuncu için Roblox Premium satın alma penceresini açar.
-
Script'in Doğru Yerde Olduğundan Emin Olun:
- LocalScript'inizin mutlaka butonun içinde olduğundan ve bir LocalScript olduğundan emin olun. Çünkü LocalScript'ler sadece client tarafında çalışır ve
LocalPlayer'a erişebilirler.
-
Oyunu Test Edin:
- Oyunu "Play" modunda çalıştırın ve butona tıklayın. Roblox Premium satın alma promptunun açıldığını göreceksiniz.
Not: Bu işlemi yapabilmek için oyununuzun Roblox tarafından onaylanan bir oyun olması ve ilgili hizmetleri kullanmak için gerekli izinlere sahip olmanız gerekmektedir.
Bu şekilde, butona tıklandığında oyuncularınıza Roblox'un kendi Premium satın alma ekranını gösterebilirsiniz.
English Translation (for clarity):
In Roblox Studio, to run Roblox's own Premium purchase prompt when a LocalScript parented button is clicked, follow these steps:
-
Create Your Button:
- First, add a TextButton or ImageButton inside a ScreenGui. This will be the button players click.
-
Add a LocalScript:
- Add a LocalScript inside your button (i.e., as a child of the button).
-
Contents of the LocalScript:
- Add the following code to your LocalScript:
local MarketplaceService = game:GetService("MarketplaceService")
local player = game.Players.LocalPlayer
local button = script.Parent -- The parent button of this script
button.MouseButton1Click:Connect(function()
MarketplaceService:PromptPremiumPurchase(player)
end)
Explanation:
MarketplaceService: A service used in Roblox for in-game purchases.
player: We get the current player using LocalPlayer in a LocalScript.
button: We reference the button which is the parent of the script.
MouseButton1Click: An event fired when the button is clicked.
PromptPremiumPurchase(player): Opens the Roblox Premium purchase prompt for the specified player.
-
Ensure the Script is in the Correct Place:
- Make sure your LocalScript is inside the button and that it is a LocalScript (because LocalScripts run on the client and can access
LocalPlayer).
-
Test the Game:
- Run the game in "Play" mode and click the button. You should see the Roblox Premium purchase prompt appear.
By doing this, you can show Roblox's own Premium purchase screen to players when they click the button.
Note: This answer provides the exact instructions and code necessary to accomplish what the user asked for in their Roblox game.