scefs

script

Aug 16th, 2025
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. local MPS = game:GetService("MarketplaceService")
  2. local Players = game:GetService("Players")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4.  
  5. local player = Players.LocalPlayer
  6. local skipStageButton = script.Parent -- This script should be a child of the ImageButton
  7. local DEVELOPER_PRODUCT_ID = 3359006786 -- Replace with your actual Developer Product ID
  8.  
  9. local skipStageEvent = ReplicatedStorage:WaitForChild("SkipStageRequest")
  10.  
  11. local MAX_FREE_SKIPS = 5
  12. local freeSkipsLeft = 0
  13.  
  14. -- Group ID for free skip countdown feature
  15. local GROUP_ID = 289054289
  16.  
  17. -- Countdown settings
  18. local COUNTDOWN_TIME = 300 -- 5 minutes (300 seconds)
  19. local countdown = COUNTDOWN_TIME
  20.  
  21. -- Reference to the SkipsLeft TextLabel in PlayerGui
  22. local skipsLeftLabel = nil
  23. local countdownLabel = nil
  24.  
  25. local function findSkipsLeftLabel()
  26. local playerGui = player:FindFirstChild("PlayerGui")
  27. if playerGui then
  28. local displaySkips = playerGui:FindFirstChild("DisplaySkips")
  29. if displaySkips then
  30. return displaySkips:FindFirstChild("SkipsLeft")
  31. end
  32. end
  33. return nil
  34. end
  35.  
  36. local function findCountdownLabel()
  37. local playerGui = player:FindFirstChild("PlayerGui")
  38. if playerGui then
  39. local displaySkips = playerGui:FindFirstChild("DisplaySkips")
  40. if displaySkips then
  41. return displaySkips:FindFirstChild("Countdown")
  42. end
  43. end
  44. return nil
  45. end
  46.  
  47. -- Function to update the SkipsLeft label
  48. local function updateSkipsLeftLabel()
  49. if not skipsLeftLabel then
  50. skipsLeftLabel = findSkipsLeftLabel()
  51. end
  52. if skipsLeftLabel then
  53. skipsLeftLabel.Text = "Free Skips Left: " .. tostring(freeSkipsLeft) .. " / " .. tostring(MAX_FREE_SKIPS)
  54. skipsLeftLabel.Visible = true
  55. end
  56. end
  57.  
  58. local function formatTime(seconds)
  59. local minutes = math.floor(seconds / 60)
  60. local secs = seconds % 60
  61. return string.format("%02d:%02d", minutes, secs)
  62. end
  63.  
  64. local function updateCountdownLabel()
  65. if not countdownLabel then
  66. countdownLabel = findCountdownLabel()
  67. end
  68. if countdownLabel then
  69. if freeSkipsLeft >= MAX_FREE_SKIPS then
  70. countdownLabel.Text = "Max free skip reached"
  71. countdownLabel.Visible = true
  72. else
  73. countdownLabel.Text = "Next Free Skip In: " .. formatTime(countdown)
  74. countdownLabel.Visible = true
  75. end
  76. end
  77. end
  78.  
  79. -- For non-group members, update UI to show group-only feature
  80. local function setGroupOnlyUI()
  81. if not skipsLeftLabel then
  82. skipsLeftLabel = findSkipsLeftLabel()
  83. end
  84. if not countdownLabel then
  85. countdownLabel = findCountdownLabel()
  86. end
  87. if skipsLeftLabel then
  88. skipsLeftLabel.Text = "Join our group for free skips!"
  89. skipsLeftLabel.Visible = true
  90. end
  91. if countdownLabel then
  92. countdownLabel.Text = "Free skips are a group feature"
  93. countdownLabel.Visible = false
  94. end
  95. end
  96.  
  97. local function onPromptProductPurchaseFinished(plr, productId, wasPurchased)
  98. if plr == player and productId == DEVELOPER_PRODUCT_ID and wasPurchased then
  99. skipStageEvent:FireServer()
  100. end
  101. end
  102.  
  103. -- Main logic
  104. if player:IsInGroup(GROUP_ID) then
  105. -- Initial update
  106. updateSkipsLeftLabel()
  107. updateCountdownLabel()
  108.  
  109. skipStageButton.MouseButton1Click:Connect(function()
  110. if freeSkipsLeft > 0 then
  111. freeSkipsLeft = freeSkipsLeft - 1
  112. updateSkipsLeftLabel()
  113. skipStageEvent:FireServer()
  114. -- If we just dropped below max, restart timer and show countdown again
  115. if freeSkipsLeft == MAX_FREE_SKIPS - 1 then
  116. countdown = COUNTDOWN_TIME
  117. updateCountdownLabel()
  118. end
  119. else
  120. MPS:PromptProductPurchase(player, DEVELOPER_PRODUCT_ID)
  121. end
  122. end)
  123.  
  124. MPS.PromptProductPurchaseFinished:Connect(onPromptProductPurchaseFinished)
  125.  
  126. -- Timer loop
  127. task.spawn(function()
  128. while true do
  129. if freeSkipsLeft < MAX_FREE_SKIPS then
  130. if countdown > 0 then
  131. countdown = countdown - 1
  132. else
  133. freeSkipsLeft = freeSkipsLeft + 1
  134. updateSkipsLeftLabel()
  135. countdown = COUNTDOWN_TIME
  136. end
  137. updateCountdownLabel()
  138. else
  139. -- If max skips, show max message and pause timer
  140. countdown = 0
  141. updateCountdownLabel()
  142. -- Wait until a skip is used before resuming timer
  143. repeat
  144. task.wait(0.5)
  145. until freeSkipsLeft < MAX_FREE_SKIPS
  146. countdown = COUNTDOWN_TIME
  147. updateCountdownLabel()
  148. end
  149. task.wait(1)
  150. end
  151. end)
  152.  
  153. -- Listen for PlayerGui changes in case the GUI reloads (e.g., after reset)
  154. player.CharacterAdded:Connect(function()
  155. skipsLeftLabel = nil
  156. countdownLabel = nil
  157. task.wait(1)
  158. updateSkipsLeftLabel()
  159. updateCountdownLabel()
  160. end)
  161. else
  162. -- Not in group: disable free skip logic, update UI
  163. setGroupOnlyUI()
  164. skipStageButton.MouseButton1Click:Connect(function()
  165. MPS:PromptProductPurchase(player, DEVELOPER_PRODUCT_ID)
  166. end)
  167. -- Listen for PlayerGui changes in case the GUI reloads (e.g., after reset)
  168. player.CharacterAdded:Connect(function()
  169. skipsLeftLabel = nil
  170. countdownLabel = nil
  171. task.wait(1)
  172. setGroupOnlyUI()
  173. end)
  174. end
  175.  
  176.  
Advertisement
Add Comment
Please, Sign In to add comment