Advertisement
Guest User

adoman, my work

a guest
Dec 11th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.67 KB | None | 0 0
  1.  
  2. --[[
  3.  
  4. Here is what a client menu framework would look like,
  5. lots of assets being preloaded, to ensure the stability of the game (client side)
  6. Also demonstrating some different usages of remote client events/functions.
  7.  
  8. ]]
  9.  
  10. local sl = require(game.ReplicatedStorage.ModuleScripts.CrossNetwork.ShopLogic)
  11. local cgm = require(game.ReplicatedStorage.ModuleScripts.CrossNetwork.CandyGlobalModules)
  12. local gd = require(game.ReplicatedStorage.ModuleScripts.CrossNetwork.GameData)
  13. local gm = require(game.ReplicatedStorage.ModuleScripts.CrossNetwork.GenericGlobalModules)
  14. local bm = require(game.ReplicatedStorage.ModuleScripts.CrossNetwork.BuyableModule)
  15.  
  16. local MarketplaceService = game:GetService("MarketplaceService")
  17.  
  18. local m = {}
  19.  
  20. m.Init = function(plr)
  21. local plrGui = plr:WaitForChild('PlayerGui')
  22. local plrLollis = plrGui:WaitForChild('Lollis')
  23. local plrBackpacks = plrGui:WaitForChild('Backpacks')
  24. local plrInventory = plrGui:WaitForChild('Inventory')
  25. local plrMainFrame = plrGui:WaitForChild('MainFrame')
  26. local plrValueFrame = plrGui:WaitForChild('ValueFrame')
  27. local plrBuyMore = plrGui:WaitForChild('BuyMore')
  28. local plrInv = plrGui:WaitForChild('Inventory')
  29. local plrGs = plrGui:WaitForChild('GamepassShop')
  30.  
  31. local settingsBtn = plrMainFrame.Frame:WaitForChild('Settings')
  32. local twitterBtn = plrMainFrame.Frame:WaitForChild('Twitter')
  33. local tradingBtn = plrMainFrame.Frame:WaitForChild('Trading')
  34. local sellBtn = plrMainFrame.Frame:WaitForChild('Sell')
  35. local backpackBtn = plrMainFrame.Frame:WaitForChild('Backpack')
  36. local gamepassBtn = plrMainFrame.Frame:WaitForChild('Gamepasses')
  37.  
  38. local settingsFrame = plrMainFrame:WaitForChild('SettingsFrame')
  39. local twitterFrame = plrMainFrame:WaitForChild('TwitterFrame')
  40. local tradingFrame = plrMainFrame:WaitForChild('TradingFrame')
  41.  
  42. local rebirths = plrValueFrame.Frame:WaitForChild('Rebirths')
  43. local cash = plrValueFrame.Frame:WaitForChild('Cash')
  44. local candy = plrValueFrame.Frame:WaitForChild('Candy')
  45.  
  46. settingsBtn.MouseButton1Click:Connect(function()
  47. settingsFrame.Visible = not settingsFrame.Visible
  48. twitterFrame.Visible = false
  49. tradingFrame.Visible = false
  50. end)
  51. twitterBtn.MouseButton1Click:Connect(function()
  52. twitterFrame.Visible = not twitterFrame.Visible
  53. settingsFrame.Visible = false
  54. tradingFrame.Visible = false
  55. end)
  56. sellBtn.MouseButton1Click:Connect(function()
  57. game.ReplicatedStorage.RemoteEvents.GotoSell:FireServer()
  58. end)
  59. tradingBtn.MouseButton1Click:Connect(function()
  60. tradingFrame.Visible = not tradingFrame.Visible
  61. twitterFrame.Visible = false
  62. settingsFrame.Visible = false
  63. end)
  64. backpackBtn.MouseButton1Click:Connect(function()
  65. plrInventory.Enabled = not plrInventory.Enabled
  66. end)
  67. gamepassBtn.MouseButton1Click:Connect(function()
  68. plrGs.Enabled = not plrGs.Enabled
  69. end)
  70.  
  71.  
  72. settingsFrame.CloseBtn.MouseButton1Click:Connect(function()
  73. settingsFrame.Visible = not settingsFrame.Visible
  74. end)
  75. tradingFrame.CloseBtn.MouseButton1Click:Connect(function()
  76. tradingFrame.Visible = not tradingFrame.Visible
  77. end)
  78. twitterFrame.CloseBtn.MouseButton1Click:Connect(function()
  79. twitterFrame.Visible = not twitterFrame.Visible
  80. end)
  81.  
  82. settingsFrame.DisableCandyAnims.MouseButton1Click:Connect(function()
  83. if settingsFrame.DisableCandyAnims.Frame.ImageTransparency == 1 then
  84. settingsFrame.DisableCandyAnims.Frame.ImageTransparency = 0
  85. settingsFrame.EnableCandyAnims.Frame.ImageTransparency = 1
  86. end
  87. end)
  88. settingsFrame.EnableCandyAnims.MouseButton1Click:Connect(function()
  89. if settingsFrame.EnableCandyAnims.Frame.ImageTransparency == 1 then
  90. settingsFrame.EnableCandyAnims.Frame.ImageTransparency = 0
  91. settingsFrame.DisableCandyAnims.Frame.ImageTransparency = 1
  92. end
  93. end)
  94. settingsFrame.DisableCandyNotifications.MouseButton1Click:Connect(function()
  95. if settingsFrame.DisableCandyNotifications.Frame.ImageTransparency == 1 then
  96. settingsFrame.DisableCandyNotifications.Frame.ImageTransparency = 0
  97. settingsFrame.EnableCandyNotifications.Frame.ImageTransparency = 1
  98. end
  99. end)
  100. settingsFrame.EnableCandyNotifications.MouseButton1Click:Connect(function()
  101. if settingsFrame.EnableCandyNotifications.Frame.ImageTransparency == 1 then
  102. settingsFrame.EnableCandyNotifications.Frame.ImageTransparency = 0
  103. settingsFrame.DisableCandyNotifications.Frame.ImageTransparency = 1
  104. end
  105. end)
  106. settingsFrame.DisableTrading.MouseButton1Click:Connect(function()
  107. if settingsFrame.DisableTrading.Frame.ImageTransparency == 1 then
  108. local rv = game.ReplicatedStorage.RemoteFunctions.Trading:InvokeServer()
  109. repeat wait() until rv == true
  110. settingsFrame.DisableTrading.Frame.ImageTransparency = 0
  111. settingsFrame.EnableTrading.Frame.ImageTransparency = 1
  112. end
  113. end)
  114. settingsFrame.EnableTrading.MouseButton1Click:Connect(function()
  115. if settingsFrame.EnableTrading.Frame.ImageTransparency == 1 then
  116. local rv = game.ReplicatedStorage.RemoteFunctions.Trading:InvokeServer()
  117. repeat wait() until rv == true
  118. settingsFrame.EnableTrading.Frame.ImageTransparency = 0
  119. settingsFrame.DisableTrading.Frame.ImageTransparency = 1
  120. end
  121. end)
  122.  
  123. game.Players[plr.Name].leaderstats.Coins.Changed:Connect(function()
  124. cash.TextLabel.Text = gm.ConvertNumToText(game.Players[plr.Name].leaderstats.Coins.Value)
  125. end)
  126. game.Players[plr.Name].leaderstats.Rebirths.Changed:Connect(function()
  127. rebirths.TextLabel.Text = gm.ConvertNumToText(game.Players[plr.Name].leaderstats.Rebirths.Value)
  128. end)
  129. game.Players[plr.Name].leaderstats.Candy.Changed:Connect(function()
  130. candy.TextLabel.Text = gm.ConvertNumToText(game.Players[plr.Name].leaderstats.Candy.Value)
  131. end)
  132. game.Players[plr.Name].leaderstats['Rebirth Gems'].Changed:Connect(function()
  133. candy.TextLabel.Text = gm.ConvertNumToText(game.Players[plr.Name].leaderstats['Rebirth Gems'].Value)
  134. end)
  135.  
  136.  
  137. spawn(function()
  138. wait(1)
  139. candy.TextLabel.Text = gm.ConvertNumToText(game.Players[plr.Name].leaderstats['Rebirth Gems'].Value)
  140. cash.TextLabel.Text = gm.ConvertNumToText(game.Players[plr.Name].leaderstats.Coins.Value)
  141. rebirths.TextLabel.Text = gm.ConvertNumToText(game.Players[plr.Name].leaderstats.Rebirths.Value)
  142. candy.TextLabel.Text = gm.ConvertNumToText(game.Players[plr.Name].leaderstats.Candy.Value)
  143. end)
  144.  
  145. plrLollis.ImageLabel.CloseBtn.MouseButton1Click:Connect(function()
  146. if plr:FindFirstChild('whichShop') then
  147. local v = plr.whichShop.Value
  148. plr.whichShop:Destroy()
  149. game.ReplicatedStorage.RemoteEvents.MoveBack:FireServer('lolli')
  150. sl.ClientExitStores(plr)
  151. end
  152. end)
  153. plrBackpacks.ImageLabel.CloseBtn.MouseButton1Click:Connect(function()
  154. if plr:FindFirstChild('whichShop') then
  155. local v = plr.whichShop.Value
  156. plr.whichShop:Destroy()
  157. game.ReplicatedStorage.RemoteEvents.MoveBack:FireServer('backpacks')
  158. sl.ClientExitStores(plr)
  159. end
  160. end)
  161.  
  162. plrBackpacks.Left.MouseButton1Click:Connect(function()
  163. sl.MoveLeft(plr, 'backpacks')
  164. end)
  165. plrBackpacks.Right.MouseButton1Click:Connect(function()
  166. sl.MoveRight(plr, 'backpacks')
  167. end)
  168.  
  169. plrBackpacks.ImageLabel.BuyBtn.MouseButton1Click:Connect(function()
  170. game.ReplicatedStorage.RemoteEvents.Buy:FireServer('backpacks', plrBackpacks.ImageLabel.BuyBtn.Parent.ItemName.Text)
  171. end)
  172.  
  173. plrLollis.Left.MouseButton1Click:Connect(function()
  174. sl.MoveLeft(plr, 'lollipops')
  175. end)
  176. plrLollis.Right.MouseButton1Click:Connect(function()
  177. sl.MoveRight(plr, 'lollipops')
  178. end)
  179.  
  180. plrLollis.ImageLabel.BuyBtn.MouseButton1Click:Connect(function()
  181. game.ReplicatedStorage.RemoteEvents.Buy:FireServer('lollipops', plrLollis.ImageLabel.BuyBtn.Parent.ItemName.Text)
  182. end)
  183.  
  184. game.ReplicatedStorage.PlayerData[tostring(plr.UserId)].UnlockedBackpacks.ChildAdded:Connect(function()
  185. cgm.UpdateEquip(plr, 'backpacks')
  186. end)
  187. game.ReplicatedStorage.PlayerData[tostring(plr.UserId)].UnlockedBackpacks.ChildRemoved:Connect(function()
  188. cgm.UpdateEquip(plr, 'backpacks')
  189. end)
  190.  
  191. game.ReplicatedStorage.PlayerData[tostring(plr.UserId)].UnlockedLollis.ChildAdded:Connect(function()
  192. cgm.UpdateEquip(plr, 'lollipops')
  193. end)
  194. game.ReplicatedStorage.PlayerData[tostring(plr.UserId)].UnlockedLollis.ChildRemoved:Connect(function()
  195. cgm.UpdateEquip(plr, 'lollipops')
  196. end)
  197.  
  198. delayTime = false
  199. plrBackpacks.ImageLabel.Equip.MouseButton1Click:Connect(function()
  200. if not delayTime then
  201. delayTime = true
  202. local retValue = game.ReplicatedStorage.RemoteFunctions.Equip:InvokeServer(plrBackpacks.ImageLabel.ItemName.Text, 'equip', 'backpacks')
  203. repeat wait() until retValue == true
  204. delayTime = false
  205. end
  206. end)
  207. plrBackpacks.ImageLabel.UnEquip.MouseButton1Click:Connect(function()
  208. if not delayTime then
  209. delayTime = true
  210. local retValue = game.ReplicatedStorage.RemoteFunctions.Equip:InvokeServer(plrBackpacks.ImageLabel.ItemName.Text, 'unequip', 'backpacks')
  211. repeat wait() until retValue == true
  212. delayTime = false
  213. end
  214. end)
  215.  
  216. plrLollis.ImageLabel.Equip.MouseButton1Click:Connect(function()
  217. if not delayTime then
  218. delayTime = true
  219. local retValue = game.ReplicatedStorage.RemoteFunctions.Equip:InvokeServer(plrLollis.ImageLabel.ItemName.Text, 'equip', 'lollipops')
  220. repeat wait() until retValue == true
  221. delayTime = false
  222. end
  223. end)
  224. plrLollis.ImageLabel.UnEquip.MouseButton1Click:Connect(function()
  225. if not delayTime then
  226. delayTime = true
  227. local retValue = game.ReplicatedStorage.RemoteFunctions.Equip:InvokeServer(plrLollis.ImageLabel.ItemName.Text, 'unequip', 'lollipops')
  228. repeat wait() until retValue == true
  229. delayTime = false
  230. end
  231. end)
  232.  
  233.  
  234. -- inventory
  235. local camPoint = workspace.Shops.View.CamPart
  236. local camSubjct = workspace.Shops.View.CamSubject
  237.  
  238. local selected
  239. local category
  240. local categoryTypes = {'pets', 'hats', 'backpacks', 'lollipops'}
  241.  
  242. local subConn
  243. lastRot = 0.025
  244. conns = {}
  245.  
  246. plrInv.ImageLabel.Close.MouseButton1Click:Connect(function()
  247. plrInv.Enabled = false
  248. subConn = nil
  249. plrInv.ImageLabel.Item:ClearAllChildren()
  250. end)
  251.  
  252. local function hideFrames()
  253. for k,v in pairs(plrInv.ImageLabel:GetChildren()) do
  254. if v:IsA('ScrollingFrame') and v.Name ~= 'SelectFrame' then
  255. for x,y in pairs(v:GetChildren()) do
  256. for i=1, #conns do conns[i]:Disconnect() end
  257. conns = {} -- after disconnecting the connections ensure new table
  258. if y:IsA('TextButton') then y:Destroy() end
  259. end
  260. v.Visible = false
  261. end
  262. end
  263. for k,v in pairs(plrInv.ImageLabel:GetChildren()) do
  264. if v:IsA('TextLabel') then
  265. v.Visible = false
  266. end
  267. end
  268. end
  269.  
  270. local tBtn = plrInv.ImageLabel.Lollipops.TextButton:Clone()
  271. plrInv.ImageLabel.Lollipops.TextButton:Destroy()
  272.  
  273. local plrData = game.ReplicatedStorage.PlayerData[tostring(plr.UserId)]
  274. local ulp = plrData.UnlockedPets
  275. local eqp = plrData.EquipedPets
  276. local ull = plrData.UnlockedLollis
  277. local eql = plrData.EquipedLolli
  278. local ulb = plrData.UnlockedBackpacks
  279. local eqb = plrData.EquipedBackpack
  280. local ulh = plrData.UnlockedHats
  281. local eqh = plrData.EquipedHats
  282.  
  283. local toUpdateDirs = {ulp, eqp, ull, eql, ulb, eqb, ulh, eqh}
  284. local toUpdateDirsPar = {'Pets', 'Pets', 'Lollipops', 'Lollipops', 'Backpacks', 'Backpacks', 'Hats', 'Hats'}
  285.  
  286. plrInv.ImageLabel.Equip.MouseButton1Click:Connect(function()
  287. db = false
  288. if not db then
  289. db = true
  290. if selected then
  291. local retValue = game.ReplicatedStorage.RemoteFunctions.Equip:InvokeServer(selected.Text, 'equip', category)
  292. repeat wait() until retValue == true or retValue == -1
  293. end
  294. db = false
  295. end
  296. end)
  297. plrInv.ImageLabel.UnEquip.MouseButton1Click:Connect(function()
  298. db = false
  299. if not db then
  300. db = true
  301. if selected then
  302. local retValue = game.ReplicatedStorage.RemoteFunctions.Equip:InvokeServer(selected.Text, 'unequip', category)
  303. repeat wait() until retValue == true or retValue == -1
  304. end
  305. db = false
  306. end
  307. end)
  308.  
  309. local viewPort = Instance.new('Camera')
  310. plrInv.ImageLabel.Item.CurrentCamera = viewPort
  311. viewPort.Parent = plrInv.ImageLabel.Item
  312.  
  313. ictn = 1
  314. game:GetService('RunService').RenderStepped:Connect(function()
  315. if ictn > 360 then ictn = 1 end
  316. lastRot = ictn + 0.025
  317. ictn = ictn + 1
  318. end)
  319.  
  320. viewPort.CFrame = CFrame.new(camPoint.Position+Vector3.new(0, 0, 6), camSubjct.Position)
  321.  
  322. local function findData(area)
  323. for k,v in pairs(gd[area]) do
  324. if v[1] == selected.Text then
  325. return v
  326. end
  327. end
  328. end
  329.  
  330. local function findItem(dir, itemName)
  331. for k,v in pairs(dir:GetDescendants()) do
  332. if v.Name == itemName then return v:Clone() end
  333. end
  334. end
  335.  
  336. local function attatchHandle(btn, area)
  337. local conn = btn.MouseButton1Click:Connect(function()
  338. if subConn then subConn:Disconnect() end
  339. subConn = nil
  340.  
  341. local otherAreas = {plrInv.ImageLabel.Backpacks, plrInv.ImageLabel.Hats, plrInv.ImageLabel.Lollipops, plrInv.ImageLabel.Pets}
  342. for x, y in pairs(otherAreas) do
  343. for k,v in pairs(y:GetDescendants()) do
  344. if v:IsA('TextButton') then
  345. if tostring(v.TextColor) == tostring(BrickColor.new('Really black')) then
  346. v.TextColor = BrickColor.new(Color3.fromRGB(255, 255, 255))
  347. end
  348. end
  349. end
  350. end
  351.  
  352. if selected == btn and tostring(btn.TextColor)==tostring(BrickColor.new('Really black')) then
  353. btn.TextColor = BrickColor.new(Color3.fromRGB(255, 255, 255))
  354. end
  355.  
  356. selected = btn
  357.  
  358. -- make updates on data
  359. local data = findData(area)
  360. if area == 'Lollipops' then
  361. plrInv.ImageLabel.LollipopsData.ItemName.Text = data[1]
  362. plrInv.ImageLabel.LollipopsData.Multiplier.Text = 'x' .. gm.ConvertNumToText(data[3])
  363. elseif area == 'Backpacks' then
  364. plrInv.ImageLabel.BackpacksData.ItemName.Text = data[1]
  365. plrInv.ImageLabel.BackpacksData.Storage.Text = gm.ConvertNumToText(data[3]) .. ' spaces'
  366. elseif area == 'Hats' then
  367. plrInv.ImageLabel.HatsData.ItemName.Text = data[1]
  368. plrInv.ImageLabel.HatsData.Multiplier.Text = 'x' .. gm.ConvertNumToText(data[2])
  369. plrInv.ImageLabel.HatsData.SpeedMultiplier.Text = 'x' .. data[3]
  370. elseif area == 'Pets' then
  371. plrInv.ImageLabel.PetsData.ItemName.Text = data[1]
  372. plrInv.ImageLabel.PetsData.Multiplier.Text = 'x' .. gm.ConvertNumToText(data[2])
  373. plrInv.ImageLabel.PetsData.SpeedMultiplier.Text = 'x' .. data[3]
  374. end
  375.  
  376. -- setup viewport
  377. plrInv.ImageLabel.Item:ClearAllChildren()
  378. local p = findItem(game.ReplicatedStorage.GameObjects[area], btn.Text)
  379.  
  380. p:SetPrimaryPartCFrame(camSubjct.CFrame)
  381. spawn(function()
  382. local myconn = game:GetService('RunService').RenderStepped:Connect(function()
  383. pcall(function()
  384. local cf = CFrame.new()
  385. cf = CFrame.new(p:GetPrimaryPartCFrame().p) * CFrame.Angles(0, math.rad(lastRot), 0)
  386. p:SetPrimaryPartCFrame(cf)
  387. end)
  388. end)
  389. repeat wait() until p.PrimaryPart == nil
  390. myconn:Disconnect()
  391. end)
  392. wait(.01)
  393. p.Parent = plrInv.ImageLabel.Item
  394.  
  395. end)
  396. conns[#conns+1] = conn
  397. end
  398.  
  399. local gAmt
  400.  
  401. local function getAmount(dir, objName)
  402. gAmt = 0
  403. for k,v in pairs(dir:GetDescendants()) do
  404. if v.Name == objName then
  405. gAmt = gAmt + 1
  406. end
  407. end
  408. return gAmt
  409. end
  410.  
  411. local function getColoredAmount(toUpdate, objName)
  412. local dir = plrInv.ImageLabel[toUpdate]
  413. gAmt = 0
  414. for k,v in pairs(dir:GetDescendants()) do
  415. if v:IsA('TextButton') then
  416. if v.Text == objName then
  417. gAmt = gAmt + 1
  418. end
  419. end
  420. end
  421. return gAmt
  422. end
  423.  
  424. local function updateEquiped(btn, toUpdate)
  425. local eDirs = {eqp, eql, eqb, eqh}
  426. for k,v in pairs(eDirs) do
  427. for x,y in pairs(v:GetDescendants()) do
  428. if btn.Text == y.Name then
  429. local amt = getAmount(v, y.Name)
  430. local camt = getColoredAmount(toUpdate, y.Name)
  431. if camt <= amt then
  432. btn.TextColor = BrickColor.new(Color3.fromRGB(0, 255, 45))
  433. end
  434. return -- ensure not more than one is done
  435. end
  436. end
  437. end
  438. end
  439.  
  440. local framesToUpdate = {'Pets', 'Lollipops', 'Backpacks', 'Hats'}
  441.  
  442. local function updateInv(toUpdate)
  443. for k,v in pairs(toUpdateDirs) do
  444. if toUpdateDirsPar[k] == toUpdate then
  445. for x,y in pairs(v:GetChildren()) do
  446. local btn = tBtn:Clone()
  447. btn.Text = y.Name
  448.  
  449. attatchHandle(btn, toUpdate)
  450. btn.Parent = plrInv.ImageLabel[toUpdate]
  451. updateEquiped(btn, toUpdate)
  452. end
  453. end
  454. end
  455.  
  456. for k,v in pairs(framesToUpdate) do
  457. local f = plrInv.ImageLabel[v]
  458. local scaleY = #f:GetChildren() * 0.05
  459. f.CanvasSize = UDim2.new(0, 0, scaleY, 0)
  460. end
  461. end
  462.  
  463. local dirsToWatch = {
  464. {'Pets', {ulp, eqp}},
  465. {'Lollipops', {ull, eql}},
  466. {'Backpacks', {ulb, eqp}},
  467. {'Hats', {ulh, eqh}},
  468. }
  469.  
  470. for k,v in pairs(dirsToWatch) do
  471. for x,y in pairs(v[2]) do
  472. y.ChildAdded:Connect(function()
  473. hideFrames()
  474. plrInv.ImageLabel[v[1]].Visible = true
  475. plrInv.ImageLabel[v[1] .. 'Data'].Visible = true
  476. updateInv(v[1])
  477. end)
  478. y.ChildRemoved:Connect(function()
  479. hideFrames()
  480. plrInv.ImageLabel[v[1]].Visible = true
  481. plrInv.ImageLabel[v[1] .. 'Data'].Visible = true
  482. updateInv(v[1])
  483. end)
  484. end
  485. end
  486.  
  487. for k,v in pairs(plrInv.ImageLabel.SelectFrame:GetChildren()) do
  488. if v:IsA('TextButton') then
  489. v.MouseButton1Click:Connect(function()
  490. category = string.lower(v.Text)
  491. hideFrames()
  492. plrInv.ImageLabel[v.Text].Visible = true
  493. plrInv.ImageLabel[v.Text .. 'Data'].Visible = true
  494. updateInv(v.Text)
  495. end)
  496. end
  497. end
  498.  
  499. -- gamepass shop
  500. local pass = plrGs.ImageLabel.ScrollingFrame.ImageLabel:Clone()
  501. plrGs.ImageLabel.ScrollingFrame.ImageLabel:Destroy()
  502.  
  503. local passTable = bm.GetPasses()
  504. plrGs.ImageLabel.ScrollingFrame.CanvasSize = UDim2.new(0, 0, #passTable*.2+0.43, 0)
  505.  
  506. for k,v in pairs(passTable) do
  507. local i = MarketplaceService:GetProductInfo(v[1], Enum.InfoType.GamePass)
  508. local n = i.Name
  509. local d = i.Description
  510. local r = i.PriceInRobux
  511.  
  512. local cp = pass:Clone()
  513. cp.Desc.Text = d
  514. cp.Title.Text = n
  515. cp.Cost.TextButton.Text = 'R $' .. tostring(r)
  516. cp.Img.Image = 'rbxassetid://' .. tostring(i.IconImageAssetId)
  517.  
  518. spawn(function()
  519. cp.Cost.TextButton.MouseButton1Click:Connect(function()
  520. local hasPass = false
  521.  
  522. local success, message = pcall(function()
  523. hasPass = MarketplaceService:UserOwnsGamePassAsync(plr.UserId, v[1])
  524. end)
  525.  
  526. if not success then
  527. warn("Error while checking if player has pass: " .. tostring(message))
  528. return
  529. end
  530.  
  531. if not hasPass then
  532. MarketplaceService:PromptGamePassPurchase(plr, v[1])
  533. end
  534. end)
  535. end)
  536.  
  537. cp.Parent = plrGs.ImageLabel.ScrollingFrame
  538. end
  539.  
  540. plrGs.ImageLabel.Close.MouseButton1Click:Connect(function()
  541. plrGs.Enabled = false
  542. end)
  543.  
  544.  
  545. local parts = plrValueFrame.Frame:GetChildren()
  546. for k,v in pairs(parts) do
  547. local obj = v.Name
  548. v.More.MouseButton1Click:Connect(function()
  549. -- in game buying
  550. end)
  551. end
  552.  
  553.  
  554. end
  555.  
  556. return m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement