AA122294

Untitled

Jun 11th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.11 KB | None | 0 0
  1. 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.
  2. 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).
  3. Struktur Proyek Roblox Studio Versi Lite
  4. Berikut adalah komponen yang akan kamu butuhkan di Roblox Studio:
  5. * Workspace:
  6. * Stand Part: Sebuah Part yang akan menjadi "stand" donasi. Di dalamnya akan ada SurfaceGui untuk menampilkan informasi.
  7. * ReplicatedStorage:
  8. * RemoteEvent: Satu untuk memicu pembelian donasi dari klien ke server (RequestDonationPurchase).
  9. * ServerScriptService:
  10. * Server Donation Handler: Script yang memproses pembelian Developer Product.
  11. * StarterGui:
  12. * ScreenGui: Berisi UI untuk tombol-tombol donasi.
  13. * StarterPlayer.StarterPlayerScripts:
  14. * Client Donation UI: Script yang menampilkan UI dan mengelola interaksi tombol donasi.
  15. Langkah-Langkah Implementasi & Script
  16. 1. Siapkan Stand Part
  17. * Di Workspace, buat sebuah Part (misalnya, sebuah Block). Atur ukurannya agar terlihat seperti stand.
  18. * Beri nama Part ini menjadi "DonationStand".
  19. * Di dalam "DonationStand" (sebagai anak), tambahkan sebuah SurfaceGui.
  20. * Di dalam SurfaceGui, tambahkan dua TextLabel:
  21. * Beri nama "OwnerNameLabel". Atur properti Text ke "Claim this stand!". TextScaled ke true. TextColor3 ke warna yang kontras.
  22. * Beri nama "DonationAmountLabel". Atur properti Text ke "Total Donasi: 0 Robux". TextScaled ke true. TextColor3 ke warna yang kontras.
  23. * Di dalam "DonationStand" (sebagai anak), tambahkan Part lain (misalnya, sebuah Block kecil). Ini akan menjadi area yang bisa disentuh untuk mengklaim stand.
  24. * Beri nama "ClaimArea". Atur CanCollide ke false dan Transparency ke 0.5 agar semi-transparan.
  25. 2. Script Stand (Server-Side)
  26. Masukkan script ini ke dalam "DonationStand" (Part yang kamu buat tadi). Ini akan mengelola siapa pemilik stand.
  27. -- Nama File: StandManager.lua
  28. -- Lokasi: Dalam Part "DonationStand" di Workspace
  29.  
  30. local stand = script.Parent
  31. local ownerNameLabel = stand.SurfaceGui:WaitForChild("OwnerNameLabel")
  32. local donationAmountLabel = stand.SurfaceGui:WaitForChild("DonationAmountLabel")
  33. local claimArea = stand:WaitForChild("ClaimArea")
  34.  
  35. local currentOwner = nil
  36. local totalDonations = 0
  37.  
  38. -- Function to reset the stand's display
  39. local function resetStandDisplay()
  40. ownerNameLabel.Text = "Claim this stand!"
  41. ownerNameLabel.TextColor3 = Color3.fromRGB(255, 255, 0) -- Yellow
  42. donationAmountLabel.Text = "Total Donasi: 0 Robux"
  43. donationAmountLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- White
  44. claimArea.CanCollide = false
  45. claimArea.Transparency = 0.5
  46. end
  47.  
  48. -- Function to update the donation amount display
  49. local function updateDonationDisplay(amount)
  50. totalDonations = totalDonations + amount
  51. donationAmountLabel.Text = "Total Donasi: " .. totalDonations .. " Robux"
  52. end
  53.  
  54. -- Event when the claim area is touched
  55. claimArea.Touched:Connect(function(hit)
  56. local player = game.Players:GetPlayerFromCharacter(hit.Parent)
  57. if player and not currentOwner then
  58. currentOwner = player
  59. ownerNameLabel.Text = player.DisplayName or player.Name -- Use DisplayName if available
  60. ownerNameLabel.TextColor3 = Color3.fromRGB(0, 255, 0) -- Green
  61. claimArea.CanCollide = false
  62. claimArea.Transparency = 1 -- Make it invisible after claimed
  63. print(player.Name .. " claimed the stand!")
  64.  
  65. -- Optionally, if you have multiple stands, you might want to disable others
  66. -- Or only allow a player to claim one stand. For this lite version,
  67. -- we assume one main stand or player is expected to claim.
  68. end
  69. end)
  70.  
  71. -- --- Remote Event for updating donation amount (from Server Donation Handler) ---
  72. -- This part needs to be connected with the Server Donation Handler script
  73. -- You will need a RemoteEvent in ReplicatedStorage for this if you want to
  74. -- update the stand's display from a separate script.
  75. -- For this "lite" version, we'll keep the donation logic separate for now,
  76. -- focusing only on displaying total donations.
  77.  
  78. -- Initial setup
  79. resetStandDisplay()
  80.  
  81. 3. Siapkan RemoteEvent
  82. * Di ReplicatedStorage, buat sebuah RemoteEvent.
  83. * Beri nama RemoteEvent ini menjadi "RequestDonationPurchase".
  84. 4. Script Penanganan Donasi (Server-Side)
  85. Masukkan script ini ke dalam ServerScriptService. Ini adalah inti dari sistem donasi.
  86. -- Nama File: ServerDonationHandler.lua
  87. -- Lokasi: ServerScriptService
  88.  
  89. local MarketplaceService = game:GetService("MarketplaceService")
  90. local Players = game:GetService("Players")
  91. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  92.  
  93. local RequestDonationPurchase = ReplicatedStorage:WaitForChild("RequestDonationPurchase")
  94.  
  95. -- --- PENTING: GANTI DENGAN ID DEVELOPER PRODUCT ASLI ANDA ---
  96. -- Anda harus membuat Developer Product ini di halaman game Anda di Roblox
  97. -- Harga yang disarankan: 5, 10, 25 Robux
  98. local DONATION_PRODUCT_IDS = {
  99. [123456789] = 5, -- Ganti 123456789 dengan Product ID untuk donasi 5 Robux
  100. [987654321] = 10, -- Ganti 987654321 dengan Product ID untuk donasi 10 Robux
  101. [112233445] = 25, -- Ganti 112233445 dengan Product ID untuk donasi 25 Robux
  102. -- Tambahkan Product ID dan jumlah Robux lainnya sesuai kebutuhan Anda
  103. }
  104. ----------------------------------------------------------------
  105.  
  106. -- Fungsi untuk memproses pembelian Developer Product
  107. local function processReceipt(receiptInfo)
  108. local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
  109. local productId = receiptInfo.ProductId
  110. local donationAmount = DONATION_PRODUCT_IDS[productId]
  111.  
  112. if not player then
  113. warn("Pemain tidak ditemukan untuk memproses penerimaan: ", receiptInfo.PlayerId)
  114. return Enum.ProductPurchaseDecision.NotProcessedYet
  115. end
  116.  
  117. if donationAmount then
  118. print(player.Name .. " berhasil mendonasikan " .. donationAmount .. " Robux.")
  119.  
  120. -- --- LOGIKA UNTUK MENAMBAHKAN DONASI KE PEMILIK STAND (JIKA ADA) ---
  121. -- Untuk versi lite ini, kita akan mencatat donasi di Output.
  122. -- Jika Anda ingin menyimpan total donasi per pemain yang memiliki stand,
  123. -- Anda perlu menggunakan DataStoreService dan mengupdate tampilan stand
  124. -- melalui RemoteEvent ke Client.
  125.  
  126. -- Contoh sederhana untuk mengupdate display stand (jika ada script StandManager di server):
  127. -- local targetStand = game.Workspace:FindFirstChild("DonationStand")
  128. -- if targetStand and targetStand:FindFirstChild("StandManager") then
  129. -- targetStand.StandManager:updateDonationDisplay(donationAmount) -- Panggil fungsi di script StandManager
  130. -- end
  131. -- Catatan: Memanggil fungsi secara langsung antar script di server lebih kompleks.
  132. -- Solusi yang lebih baik adalah menggunakan RemoteEvent dari Server ke Client untuk update UI.
  133.  
  134. return Enum.ProductPurchaseDecision.PurchaseGranted
  135. else
  136. warn("Produk ID tidak valid atau tidak ada dalam daftar donasi: ", productId)
  137. return Enum.ProductPurchaseDecision.NotProcessedYet
  138. end
  139. end
  140.  
  141. -- Hubungkan fungsi processReceipt ke MarketplaceService
  142. MarketplaceService.ProcessReceipt = processReceipt
  143.  
  144. -- Menerima permintaan pembelian dari klien
  145. RequestDonationPurchase.OnServerEvent:Connect(function(player, productId)
  146. local success, message = pcall(function()
  147. MarketplaceService:PromptProductPurchase(player, productId)
  148. end)
  149. if not success then
  150. warn("Gagal memulai pembelian produk: ", message)
  151. end
  152. end)
  153.  
  154. 5. Buat UI Donasi (Client-Side)
  155. * Di StarterGui, buat sebuah ScreenGui. Beri nama "DonationUI".
  156. * Di dalam "DonationUI", buat sebuah Frame. Beri nama "DonationPanel". Atur ukurannya agar terlihat bagus di layar (misalnya, di tengah bawah).
  157. * Di dalam "DonationPanel", tambahkan TextButton untuk setiap opsi donasi yang kamu inginkan:
  158. * Beri nama "Donate5RobuxButton". Atur Text ke "Donasi 5 Robux".
  159. * Beri nama "Donate10RobuxButton". Atur Text ke "Donasi 10 Robux".
  160. * Beri nama "Donate25RobuxButton". Atur Text ke "Donasi 25 Robux".
  161. * (Tambahkan lebih banyak jika kamu punya lebih banyak Product ID)
  162. * Sesuaikan ukuran dan posisi tombol agar rapi di dalam DonationPanel.
  163. 6. Script UI Donasi (Client-Side)
  164. Masukkan script ini ke dalam DonationUI (ScreenGui yang kamu buat tadi) atau di StarterPlayer.StarterPlayerScripts.
  165. -- Nama File: ClientDonationUI.lua
  166. -- Lokasi: Dalam ScreenGui "DonationUI" (atau StarterPlayer.StarterPlayerScripts)
  167.  
  168. local Players = game:GetService("Players")
  169. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  170.  
  171. local DonationPanel = script.Parent.DonationPanel -- Sesuaikan jika script berada di StarterPlayerScripts
  172.  
  173. local RequestDonationPurchase = ReplicatedStorage:WaitForChild("RequestDonationPurchase")
  174.  
  175. -- --- PENTING: PASTIKAN ID DEVELOPER PRODUCT SAMA DENGAN SERVER ---
  176. -- Ini harus cocok dengan yang ada di ServerDonationHandler.lua
  177. local PRODUCT_IDS = {
  178. Donate5RobuxButton = 123456789, -- Product ID untuk 5 Robux
  179. Donate10RobuxButton = 987654321, -- Product ID untuk 10 Robux
  180. Donate25RobuxButton = 112233445, -- Product ID untuk 25 Robux
  181. }
  182. ------------------------------------------------------------------
  183.  
  184. -- Fungsi untuk menghubungkan tombol dengan event pembelian
  185. local function setupDonationButton(buttonName)
  186. local button = DonationPanel:FindFirstChild(buttonName)
  187. local productId = PRODUCT_IDS[buttonName]
  188.  
  189. if button and productId then
  190. button.MouseButton1Click:Connect(function()
  191. RequestDonationPurchase:FireServer(productId)
  192. print("Meminta pembelian produk ID: " .. productId)
  193. end)
  194. else
  195. warn("Tombol atau Product ID tidak ditemukan untuk: " .. buttonName)
  196. end
  197. end
  198.  
  199. -- Hubungkan setiap tombol donasi
  200. setupDonationButton("Donate5RobuxButton")
  201. setupDonationButton("Donate10RobuxButton")
  202. setupDonationButton("Donate25RobuxButton")
  203. -- Tambahkan baris ini untuk setiap tombol donasi yang Anda buat
  204.  
  205. Langkah Penting Setelah Setup Script:
  206. * Buat Developer Products di Roblox:
  207. * Pergi ke halaman game kamu di Roblox.
  208. * Klik ikon "..." di sudut kanan atas gamemu, lalu pilih "Configure Game".
  209. * Di menu sebelah kiri, pilih "Developer Products".
  210. * Klik "CREATE NEW" dan buat Developer Product untuk setiap jumlah donasi yang kamu inginkan (misalnya, "5 Robux Donation", "10 Robux Donation", "25 Robux Donation").
  211. * Sangat penting: Catat ID unik untuk setiap Developer Product.
  212. * Ganti placeholder ID di script ServerDonationHandler.lua dan ClientDonationUI.lua dengan ID Developer Product yang sebenarnya.
  213. * Test di Game:
  214. * Mainkan game di Roblox Studio (klik tombol Play).
  215. * Coba sentuh "ClaimArea" di stand untuk mengklaimnya. Nama pemilik harusnya berubah.
  216. * Klik tombol donasi di UI. Roblox akan menampilkan prompt pembelian.
  217. * Jika pembelian berhasil, kamu akan melihat pesan di Output Studio bahwa donasi berhasil.
  218. Apa yang Bisa Ditingkatkan (dan Mengapa Ini Versi "Lite"):
  219. * 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.
  220. * Leaderboard: Jika kamu ingin menampilkan siapa yang paling banyak berdonasi, kamu butuh sistem leaderboard yang terhubung dengan DataStoreService.
  221. * 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.
  222. * Visual Donasi: Menambahkan efek visual (partikel, suara) saat donasi diterima akan membuat pengalaman lebih menarik.
  223. Versi "lite" ini memberikan dasar yang kuat untuk sistem donasi. Selamat mencoba!
  224.  
Add Comment
Please, Sign In to add comment