Advertisement
IHATEMICROWAVEOVEN

Rewards Module

Aug 3rd, 2022
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. local despawn = 60*5 -- In seconds of course
  2.  
  3. local rewards = {
  4. -- 1
  5. {["CNDTroutletCandy"]="RND1and20",["EXPExp"]="INT200",["MNYjoe"]="RND400and3000"},
  6.  
  7. -- 2
  8. {["CNDTroutletCandy"]="RND1and20",["EXPExp"]="INT200",["MNYjoe"]="RND400and3000"},
  9.  
  10. -- 3
  11. {["CNDTroutletCandy"]="RND1and20",["EXPExp"]="INT200",["MNYjoe"]="RND400and3000"}
  12. }
  13.  
  14.  
  15. local TOUCH_MANAGER = require(game.ServerScriptService.Libraries.OnTouched)
  16. local DebrisService = game:GetService("Debris")
  17.  
  18. function Reward(Stats, Enemy)
  19. local goodies = rewards[math.random(1,3)]
  20. for _, i in pairs(goodies) do
  21. local mytype = string.sub(_,1,3)
  22. if mytype == "CND" then
  23. local part = Instance.new("Part", workspace)
  24. part.CanCollide = true
  25. part.Color = Color3.new(math.random(90,125),math.random(40,50),math.random(120,140))
  26. part.Material = "SmoothPlastic"
  27. part.Reflectance = math.random(20,30)/100
  28. local size = math.random(10,20)/10
  29. part.Size = Vector3.new(size,size,size)
  30. part.Transparency = math.random(5,20)/100
  31. local gui = Instance.new("BillboardGui",part)
  32. gui.Adornee = part
  33. gui.AlwaysOnTop = true
  34. gui.Size = UDim2.new(10,0,5,0)
  35. local text = Instance.new("TextLabel",gui)
  36. text.BackgroundTransparency = 1
  37. text.Size = UDim2.new(1,0,1,0)
  38. text.TextSize = 50
  39. text.Text = string.sub(_,4,string.len(_))
  40. text.TextScaled = true
  41. gui.Active = true
  42. text.Active = true
  43.  
  44. local payout
  45. if string.sub(i,1,3) == "RND" then
  46. local my1, my2 = string.find(i,"and")
  47. payout = math.random(tonumber(string.sub(i,4,my1-1)),tonumber(string.sub(i,my2+1,string.len(i))))
  48. elseif string.sub(i,1,3) == "INT" then
  49. payout = tonumber(string.sub(i,4,string.len(i)))
  50. else
  51. payout = 100
  52. end
  53. TOUCH_MANAGER.Touched(part, function(hit)
  54. if hit then
  55. if hit.Parent:FindFirstChild("Humanoid") then
  56. local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
  57. if plr then
  58. Stats.SetStat(plr, "RareCandy", Stats.GetStat(plr, "RareCandy") + payout)
  59. part:Destroy()
  60. end
  61. end
  62. end
  63. end)
  64. part.Position = Enemy.Torso.Position + Vector3.new(0,10,0)
  65. DebrisService:AddItem(part,despawn)
  66. elseif mytype == "EXP" then
  67. local part = Instance.new("Part", workspace)
  68. part.CanCollide = true
  69. part.Color = Color3.new(math.random(80,155),math.random(80,180),255)
  70. part.Material = "Glass"
  71. part.Reflectance = math.random(30,40)/100
  72. local size = math.random(40,50)/10
  73. part.Size = Vector3.new(size,size,size)
  74. part.Transparency = 0
  75. local gui = Instance.new("BillboardGui",part)
  76. gui.Adornee = part
  77. gui.AlwaysOnTop = true
  78. gui.Size = UDim2.new(10,0,5,0)
  79. local text = Instance.new("TextLabel",gui)
  80. text.BackgroundTransparency = 1
  81. text.Size = UDim2.new(1,0,1,0)
  82. text.TextSize = 50
  83. text.Text = string.sub(_,4,string.len(_))
  84. text.TextScaled = true
  85. gui.Active = true
  86. text.Active = true
  87.  
  88. local payout
  89. if string.sub(i,1,3) == "RND" then
  90. local my1, my2 = string.find(i,"and")
  91. payout = math.random(tonumber(string.sub(i,4,my1-1)),tonumber(string.sub(i,my2+1,string.len(i))))
  92. elseif string.sub(i,1,3) == "INT" then
  93. payout = tonumber(string.sub(i,4,string.len(i)))
  94. else
  95. payout = 100
  96. end
  97. TOUCH_MANAGER.Touched(part, function(hit)
  98. if hit then
  99. if hit.Parent:FindFirstChild("Humanoid") then
  100. local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
  101. if plr then
  102. Stats.SetStat(plr, "XP", Stats.GetStat(plr, "XP") + payout)
  103. part:Destroy()
  104. end
  105. end
  106. end
  107. end)
  108. part.Position = Enemy.Torso.Position + Vector3.new(0,10,0)
  109. DebrisService:AddItem(part,despawn)
  110. elseif mytype == "MNY" then
  111. local part = Instance.new("Part", workspace)
  112. part.CanCollide = true
  113. part.Color = Color3.new(255,math.random(210,240),math.random(40,75))
  114. part.Material = "SmoothPlastic"
  115. part.Reflectance = math.random(20,30)/100
  116. local size = math.random(20,30)/10
  117. part.Size = Vector3.new(size,size,size)
  118. part.Transparency = math.random(5,20)/100
  119. local gui = Instance.new("BillboardGui",part)
  120. gui.Adornee = part
  121. gui.AlwaysOnTop = true
  122. gui.Size = UDim2.new(10,0,5,0)
  123. local text = Instance.new("TextLabel",gui)
  124. text.BackgroundTransparency = 1
  125. text.Size = UDim2.new(1,0,1,0)
  126. text.TextSize = 50
  127. text.Text = string.sub(_,4,string.len(_))
  128. text.TextScaled = true
  129. gui.Active = true
  130. text.Active = true
  131.  
  132. local payout
  133. if string.sub(i,1,3) == "RND" then
  134. local my1, my2 = string.find(i,"and")
  135. payout = math.random(tonumber(string.sub(i,4,my1-1)),tonumber(string.sub(i,my2+1,string.len(i))))
  136. elseif string.sub(i,1,3) == "INT" then
  137. payout = tonumber(string.sub(i,4,string.len(i)))
  138. else
  139. payout = 100
  140. end
  141. TOUCH_MANAGER.Touched(part, function(hit)
  142. if hit then
  143. if hit.Parent:FindFirstChild("Humanoid") then
  144. local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
  145. if plr then
  146. Stats.SetStat(plr, "Cash", Stats.GetStat(plr, "Cash") + payout)
  147. part:Destroy()
  148. end
  149. end
  150. end
  151. end)
  152. part.Position = Enemy.Torso.Position + Vector3.new(0,10,0)
  153. DebrisService:AddItem(part,despawn)
  154. end
  155. end
  156.  
  157. local bv = Instance.new("BodyVelocity", Enemy.Torso)
  158. bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  159. bv.Velocity = Vector3.new(math.random(1,20)*(math.random(0,1)-0.5)*2,math.random(50,100),math.random(1,20)*(math.random(0,1)-0.5)*2)
  160. wait()
  161. bv:Destroy()
  162. end
  163.  
  164. return Reward
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement