Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tentu, kamu ingin versi yang lebih sederhana atau "lite" dari script PLS DONATE di Roblox Studio? Aku akan buatkan versi yang fokus pada fungsionalitas inti: pemain bisa mengklaim stand dan pemain lain bisa berdonasi dengan Developer Product yang sudah ditentukan.
- Versi ini akan menghilangkan beberapa fitur lanjutan untuk menjaga kesederhanaan, dan berfokus pada satu stand per pemain (jika ada beberapa stand di dunia, pemain bisa klaim salah satunya) dan pilihan donasi tetap (misalnya, 5, 10, 25 Robux).
- Struktur Proyek Roblox Studio Versi Lite
- Berikut adalah komponen yang akan kamu butuhkan di Roblox Studio:
- * Workspace:
- * Stand Part: Sebuah Part yang akan menjadi "stand" donasi. Di dalamnya akan ada SurfaceGui untuk menampilkan informasi.
- * ReplicatedStorage:
- * RemoteEvent: Satu untuk memicu pembelian donasi dari klien ke server (RequestDonationPurchase).
- * ServerScriptService:
- * Server Donation Handler: Script yang memproses pembelian Developer Product.
- * StarterGui:
- * ScreenGui: Berisi UI untuk tombol-tombol donasi.
- * StarterPlayer.StarterPlayerScripts:
- * Client Donation UI: Script yang menampilkan UI dan mengelola interaksi tombol donasi.
- Langkah-Langkah Implementasi & Script
- 1. Siapkan Stand Part
- * Di Workspace, buat sebuah Part (misalnya, sebuah Block). Atur ukurannya agar terlihat seperti stand.
- * Beri nama Part ini menjadi "DonationStand".
- * Di dalam "DonationStand" (sebagai anak), tambahkan sebuah SurfaceGui.
- * Di dalam SurfaceGui, tambahkan dua TextLabel:
- * Beri nama "OwnerNameLabel". Atur properti Text ke "Claim this stand!". TextScaled ke true. TextColor3 ke warna yang kontras.
- * Beri nama "DonationAmountLabel". Atur properti Text ke "Total Donasi: 0 Robux". TextScaled ke true. TextColor3 ke warna yang kontras.
- * Di dalam "DonationStand" (sebagai anak), tambahkan Part lain (misalnya, sebuah Block kecil). Ini akan menjadi area yang bisa disentuh untuk mengklaim stand.
- * Beri nama "ClaimArea". Atur CanCollide ke false dan Transparency ke 0.5 agar semi-transparan.
- 2. Script Stand (Server-Side)
- Masukkan script ini ke dalam "DonationStand" (Part yang kamu buat tadi). Ini akan mengelola siapa pemilik stand.
- -- Nama File: StandManager.lua
- -- Lokasi: Dalam Part "DonationStand" di Workspace
- local stand = script.Parent
- local ownerNameLabel = stand.SurfaceGui:WaitForChild("OwnerNameLabel")
- local donationAmountLabel = stand.SurfaceGui:WaitForChild("DonationAmountLabel")
- local claimArea = stand:WaitForChild("ClaimArea")
- local currentOwner = nil
- local totalDonations = 0
- -- Function to reset the stand's display
- local function resetStandDisplay()
- ownerNameLabel.Text = "Claim this stand!"
- ownerNameLabel.TextColor3 = Color3.fromRGB(255, 255, 0) -- Yellow
- donationAmountLabel.Text = "Total Donasi: 0 Robux"
- donationAmountLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- White
- claimArea.CanCollide = false
- claimArea.Transparency = 0.5
- end
- -- Function to update the donation amount display
- local function updateDonationDisplay(amount)
- totalDonations = totalDonations + amount
- donationAmountLabel.Text = "Total Donasi: " .. totalDonations .. " Robux"
- end
- -- Event when the claim area is touched
- claimArea.Touched:Connect(function(hit)
- local player = game.Players:GetPlayerFromCharacter(hit.Parent)
- if player and not currentOwner then
- currentOwner = player
- ownerNameLabel.Text = player.DisplayName or player.Name -- Use DisplayName if available
- ownerNameLabel.TextColor3 = Color3.fromRGB(0, 255, 0) -- Green
- claimArea.CanCollide = false
- claimArea.Transparency = 1 -- Make it invisible after claimed
- print(player.Name .. " claimed the stand!")
- -- Optionally, if you have multiple stands, you might want to disable others
- -- Or only allow a player to claim one stand. For this lite version,
- -- we assume one main stand or player is expected to claim.
- end
- end)
- -- --- Remote Event for updating donation amount (from Server Donation Handler) ---
- -- This part needs to be connected with the Server Donation Handler script
- -- You will need a RemoteEvent in ReplicatedStorage for this if you want to
- -- update the stand's display from a separate script.
- -- For this "lite" version, we'll keep the donation logic separate for now,
- -- focusing only on displaying total donations.
- -- Initial setup
- resetStandDisplay()
- 3. Siapkan RemoteEvent
- * Di ReplicatedStorage, buat sebuah RemoteEvent.
- * Beri nama RemoteEvent ini menjadi "RequestDonationPurchase".
- 4. Script Penanganan Donasi (Server-Side)
- Masukkan script ini ke dalam ServerScriptService. Ini adalah inti dari sistem donasi.
- -- Nama File: ServerDonationHandler.lua
- -- Lokasi: ServerScriptService
- local MarketplaceService = game:GetService("MarketplaceService")
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RequestDonationPurchase = ReplicatedStorage:WaitForChild("RequestDonationPurchase")
- -- --- PENTING: GANTI DENGAN ID DEVELOPER PRODUCT ASLI ANDA ---
- -- Anda harus membuat Developer Product ini di halaman game Anda di Roblox
- -- Harga yang disarankan: 5, 10, 25 Robux
- local DONATION_PRODUCT_IDS = {
- [123456789] = 5, -- Ganti 123456789 dengan Product ID untuk donasi 5 Robux
- [987654321] = 10, -- Ganti 987654321 dengan Product ID untuk donasi 10 Robux
- [112233445] = 25, -- Ganti 112233445 dengan Product ID untuk donasi 25 Robux
- -- Tambahkan Product ID dan jumlah Robux lainnya sesuai kebutuhan Anda
- }
- ----------------------------------------------------------------
- -- Fungsi untuk memproses pembelian Developer Product
- local function processReceipt(receiptInfo)
- local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
- local productId = receiptInfo.ProductId
- local donationAmount = DONATION_PRODUCT_IDS[productId]
- if not player then
- warn("Pemain tidak ditemukan untuk memproses penerimaan: ", receiptInfo.PlayerId)
- return Enum.ProductPurchaseDecision.NotProcessedYet
- end
- if donationAmount then
- print(player.Name .. " berhasil mendonasikan " .. donationAmount .. " Robux.")
- -- --- LOGIKA UNTUK MENAMBAHKAN DONASI KE PEMILIK STAND (JIKA ADA) ---
- -- Untuk versi lite ini, kita akan mencatat donasi di Output.
- -- Jika Anda ingin menyimpan total donasi per pemain yang memiliki stand,
- -- Anda perlu menggunakan DataStoreService dan mengupdate tampilan stand
- -- melalui RemoteEvent ke Client.
- -- Contoh sederhana untuk mengupdate display stand (jika ada script StandManager di server):
- -- local targetStand = game.Workspace:FindFirstChild("DonationStand")
- -- if targetStand and targetStand:FindFirstChild("StandManager") then
- -- targetStand.StandManager:updateDonationDisplay(donationAmount) -- Panggil fungsi di script StandManager
- -- end
- -- Catatan: Memanggil fungsi secara langsung antar script di server lebih kompleks.
- -- Solusi yang lebih baik adalah menggunakan RemoteEvent dari Server ke Client untuk update UI.
- return Enum.ProductPurchaseDecision.PurchaseGranted
- else
- warn("Produk ID tidak valid atau tidak ada dalam daftar donasi: ", productId)
- return Enum.ProductPurchaseDecision.NotProcessedYet
- end
- end
- -- Hubungkan fungsi processReceipt ke MarketplaceService
- MarketplaceService.ProcessReceipt = processReceipt
- -- Menerima permintaan pembelian dari klien
- RequestDonationPurchase.OnServerEvent:Connect(function(player, productId)
- local success, message = pcall(function()
- MarketplaceService:PromptProductPurchase(player, productId)
- end)
- if not success then
- warn("Gagal memulai pembelian produk: ", message)
- end
- end)
- 5. Buat UI Donasi (Client-Side)
- * Di StarterGui, buat sebuah ScreenGui. Beri nama "DonationUI".
- * Di dalam "DonationUI", buat sebuah Frame. Beri nama "DonationPanel". Atur ukurannya agar terlihat bagus di layar (misalnya, di tengah bawah).
- * Di dalam "DonationPanel", tambahkan TextButton untuk setiap opsi donasi yang kamu inginkan:
- * Beri nama "Donate5RobuxButton". Atur Text ke "Donasi 5 Robux".
- * Beri nama "Donate10RobuxButton". Atur Text ke "Donasi 10 Robux".
- * Beri nama "Donate25RobuxButton". Atur Text ke "Donasi 25 Robux".
- * (Tambahkan lebih banyak jika kamu punya lebih banyak Product ID)
- * Sesuaikan ukuran dan posisi tombol agar rapi di dalam DonationPanel.
- 6. Script UI Donasi (Client-Side)
- Masukkan script ini ke dalam DonationUI (ScreenGui yang kamu buat tadi) atau di StarterPlayer.StarterPlayerScripts.
- -- Nama File: ClientDonationUI.lua
- -- Lokasi: Dalam ScreenGui "DonationUI" (atau StarterPlayer.StarterPlayerScripts)
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local DonationPanel = script.Parent.DonationPanel -- Sesuaikan jika script berada di StarterPlayerScripts
- local RequestDonationPurchase = ReplicatedStorage:WaitForChild("RequestDonationPurchase")
- -- --- PENTING: PASTIKAN ID DEVELOPER PRODUCT SAMA DENGAN SERVER ---
- -- Ini harus cocok dengan yang ada di ServerDonationHandler.lua
- local PRODUCT_IDS = {
- Donate5RobuxButton = 123456789, -- Product ID untuk 5 Robux
- Donate10RobuxButton = 987654321, -- Product ID untuk 10 Robux
- Donate25RobuxButton = 112233445, -- Product ID untuk 25 Robux
- }
- ------------------------------------------------------------------
- -- Fungsi untuk menghubungkan tombol dengan event pembelian
- local function setupDonationButton(buttonName)
- local button = DonationPanel:FindFirstChild(buttonName)
- local productId = PRODUCT_IDS[buttonName]
- if button and productId then
- button.MouseButton1Click:Connect(function()
- RequestDonationPurchase:FireServer(productId)
- print("Meminta pembelian produk ID: " .. productId)
- end)
- else
- warn("Tombol atau Product ID tidak ditemukan untuk: " .. buttonName)
- end
- end
- -- Hubungkan setiap tombol donasi
- setupDonationButton("Donate5RobuxButton")
- setupDonationButton("Donate10RobuxButton")
- setupDonationButton("Donate25RobuxButton")
- -- Tambahkan baris ini untuk setiap tombol donasi yang Anda buat
- Langkah Penting Setelah Setup Script:
- * Buat Developer Products di Roblox:
- * Pergi ke halaman game kamu di Roblox.
- * Klik ikon "..." di sudut kanan atas gamemu, lalu pilih "Configure Game".
- * Di menu sebelah kiri, pilih "Developer Products".
- * Klik "CREATE NEW" dan buat Developer Product untuk setiap jumlah donasi yang kamu inginkan (misalnya, "5 Robux Donation", "10 Robux Donation", "25 Robux Donation").
- * Sangat penting: Catat ID unik untuk setiap Developer Product.
- * Ganti placeholder ID di script ServerDonationHandler.lua dan ClientDonationUI.lua dengan ID Developer Product yang sebenarnya.
- * Test di Game:
- * Mainkan game di Roblox Studio (klik tombol Play).
- * Coba sentuh "ClaimArea" di stand untuk mengklaimnya. Nama pemilik harusnya berubah.
- * Klik tombol donasi di UI. Roblox akan menampilkan prompt pembelian.
- * Jika pembelian berhasil, kamu akan melihat pesan di Output Studio bahwa donasi berhasil.
- Apa yang Bisa Ditingkatkan (dan Mengapa Ini Versi "Lite"):
- * Penyimpanan Donasi: Saat ini, total donasi di stand akan reset setiap kali game dimulai. Untuk menyimpan total donasi secara permanen, kamu perlu menggunakan DataStoreService untuk menyimpan data pemain dan mengupdate tampilan stand ketika pemain bergabung kembali.
- * Leaderboard: Jika kamu ingin menampilkan siapa yang paling banyak berdonasi, kamu butuh sistem leaderboard yang terhubung dengan DataStoreService.
- * Banyak Stand: Jika kamu ingin banyak stand yang bisa diklaim oleh banyak pemain secara bersamaan, kamu perlu membuat sistem spawn stand otomatis atau meletakkan beberapa stand secara manual dan memodifikasi StandManager.lua agar bisa mengelola banyak stand dan memastikan satu pemain hanya bisa mengklaim satu stand.
- * Visual Donasi: Menambahkan efek visual (partikel, suara) saat donasi diterima akan membuat pengalaman lebih menarik.
- Versi "lite" ini memberikan dasar yang kuat untuk sistem donasi. Selamat mencoba!
Add Comment
Please, Sign In to add comment