DragonYTPastesWork

Untitled

Aug 25th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 KB | None | 0 0
  1. local dss = game:GetService("DataStoreService")
  2. local RedButton = dss:GetDataStore("RedTrail")
  3. local YellowButton = dss:GetDataStore("YellowTrail")
  4. local GreenButton = dss:GetDataStore("GreenTrail")
  5. local BlueButton = dss:GetDataStore("BlueTrail")
  6. local BlackButton = dss:GetDataStore("BlackTrail")
  7. local RainbowButton = dss:GetDataStore("RainbowTrail")
  8.  
  9. local rs = game:GetService("ReplicatedStorage")
  10.  
  11.  
  12. local function buy(player, click, amount)
  13. -- Check For Previous Trails
  14. local prevTrail = player.Character.Head:FindFirstChildWhichIsA("Trail")
  15.  
  16. -- Destroys Previous Trails If Not Nil
  17. if prevTrail then
  18. local prevA0 = player.Character.Head:FindFirstChild(prevTrail.Name.."TrailA0")
  19. local prevA1 = player.Character.HumanoidRootPart:FindFirstChild(prevTrail.Name.."TrailA1")
  20.  
  21. prevTrail:Destroy()
  22. prevA0:Destroy()
  23. prevA1:Destroy()
  24. end
  25.  
  26. -- Clones Bought Trail And Creates Attachments
  27. local clone = rs:WaitForChild("Trails"):FindFirstChild(click.Name):Clone()
  28. clone.Parent = player.Character.Head
  29. local a0 = Instance.new("Attachment", player.Character.Head)
  30. a0.Name = click.Name.."TrailA0"
  31. local a1 = Instance.new("Attachment", player.Character.HumanoidRootPart)
  32. a1.Name = click.Name.."TrailA1"
  33. clone.Attachment0 = a0
  34. clone.Attachment1 = a1
  35.  
  36. --Decrease Cash
  37. player:WaitForChild("leaderstats").Coins.Value = player:WaitForChild("leaderstats").Coins.Value - amount
  38.  
  39. return true
  40. end
  41.  
  42.  
  43.  
  44. rs.BuyTrail.OnServerInvoke = function(plr, button, cost)
  45. if plr:WaitForChild("leaderstats").Coins.Value >= cost then
  46. if button.Name == "RedButton" then
  47. local data = RedButton:GetAsync(plr.UserId)
  48. local bought = false
  49. if data then
  50. bought = true
  51. else
  52. bought = false
  53. end
  54. if bought == false then
  55. buy(plr, button, cost)
  56. RainbowButton:SetAsync(plr.UserId, true)
  57. end
  58. end
  59. -----------------------------------------------------------------------------------------------
  60. if button.Name == "YellowButton" then
  61. local data = YellowButton:GetAsync(plr.UserId)
  62. local bought = false
  63. if data then
  64. bought = true
  65. else
  66. bought = false
  67. end
  68. if bought == false then
  69. buy(plr, button, cost)
  70. RainbowButton:SetAsync(plr.UserId, true)
  71. end
  72. end
  73. -----------------------------------------------------------------------------------------------
  74. if button.Name == "GreenButton" then
  75. local data = GreenButton:GetAsync(plr.UserId)
  76. local bought = false
  77. if data then
  78. bought = true
  79. else
  80. bought = false
  81. end
  82. if bought == false then
  83. buy(plr, button, cost)
  84. RainbowButton:SetAsync(plr.UserId, true)
  85. end
  86. end
  87. -----------------------------------------------------------------------------------------------
  88. if button.Name == "BlueButton" then
  89. local data = BlueButton:GetAsync(plr.UserId)
  90. local bought = false
  91. if data then
  92. bought = true
  93. else
  94. bought = false
  95. end
  96. if bought == false then
  97. buy(plr, button, cost)
  98. RainbowButton:SetAsync(plr.UserId, true)
  99. end
  100. end
  101. -----------------------------------------------------------------------------------------------
  102. if button.Name == "BlackButton" then
  103. local data = BlackButton:GetAsync(plr.UserId)
  104. local bought = false
  105. if data then
  106. bought = true
  107. else
  108. bought = false
  109. end
  110. if bought == false then
  111. buy(plr, button, cost)
  112. RainbowButton:SetAsync(plr.UserId, true)
  113. end
  114. end
  115. -----------------------------------------------------------------------------------------------
  116. if button.Name == "RainbowButton" then
  117. local data = RainbowButton:GetAsync(plr.UserId)
  118. local bought = false
  119. if data then
  120. bought = true
  121. else
  122. bought = false
  123. end
  124. if bought == false then
  125. buy(plr, button, cost)
  126. RainbowButton:SetAsync(plr.UserId, true)
  127. end
  128. end
  129. end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment