Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. local pls = game:GetService("Players")
  2. local repstr = game:GetService("ReplicatedStorage")
  3. local debris = game:GetService("Debris")
  4. local ts = game:GetService("TweenService")
  5.  
  6. local itemModule = require(repstr.ItemInformation)
  7. local mInfo = itemModule.MagnetInfo
  8. local rarityColors = itemModule.RarityInfo
  9.  
  10. local tool = script.Parent
  11. local handle = tool.Handle
  12.  
  13. local collecting = 0
  14. local collectmax = 5
  15.  
  16. local animid = "rbxassetid://03486072754"
  17. local animc = Instance.new("Animation")
  18. animc.AnimationId = animid
  19.  
  20. local plr = game.Players.LocalPlayer
  21. local val = plr:WaitForChild("Zone")
  22. repeat wait() until plr.Character
  23. local char = plr.Character
  24. local root = char:WaitForChild("HumanoidRootPart")
  25. local humanoid = char:WaitForChild("Humanoid")
  26. local hold = humanoid:LoadAnimation(animc)
  27.  
  28. local eventsFolder = repstr.Events
  29. local magnetEvents = eventsFolder.MagnetEvents
  30.  
  31. local backpackHandler = require(repstr.BackpackHandler)
  32.  
  33. local grabEvent = magnetEvents.requestGrab
  34.  
  35. local coins = workspace:WaitForChild("GlobalCoins")
  36.  
  37. local coinTable = {}
  38.  
  39. local tweenInfo = TweenInfo.new(
  40. .25, -- Time
  41. Enum.EasingStyle.Quad, -- EasingStyle
  42. Enum.EasingDirection.In, -- EasingDirection
  43. 1, -- RepeatCount (when less than zero the tween will loop indefinitely)
  44. false, -- Reverses (tween will reverse once reaching it's goal)
  45. 0 -- DelayTime
  46. )
  47.  
  48. function rankCheck(coin, plr)
  49. if coin and plr then
  50. local stats = plr:WaitForChild("Stats")
  51. local tool = stats:WaitForChild("Tool")
  52.  
  53. local coinRank = coin:WaitForChild("Rank")
  54.  
  55. local plrRarity = mInfo[tool.Value][2]
  56. local plrRank = rarityColors[plrRarity][1]
  57.  
  58. return (plrRank >= coinRank.Value)
  59. end
  60. end
  61.  
  62. function returnDistance(p1, p2)
  63. if p1 and p2 then
  64. local dist = (p1.Position - p2.Position).magnitude
  65. return dist
  66. end
  67. end
  68.  
  69. function distCheck(p1, p2)
  70. if p1 and p2 then
  71. local dist = (p1.Position - p2.Position).magnitude
  72. return dist
  73. end
  74. end
  75.  
  76. tool.Equipped:connect(function()
  77. hold:Play()
  78. end)
  79.  
  80. tool.Unequipped:connect(function()
  81. hold:Stop()
  82. end)
  83.  
  84. local range = mInfo[tool.Name][1]
  85. local rarity = mInfo[tool.Name][2]
  86. local color = rarityColors[rarity][2].Color
  87. local multiplier = mInfo[tool.Name][3]
  88.  
  89. function grab(coin)
  90. local stats = plr:WaitForChild("Stats")
  91. local coins = stats:WaitForChild("Coins")
  92. local backpack = stats:WaitForChild("Backpack")
  93. local petboost = plr:WaitForChild("PetBoosts")
  94. local purchases = plr:WaitForChild("Purchases")
  95. local Type = tool:WaitForChild("Type")
  96. local check
  97. if Type.Value == "Long" then
  98. local magnet = tool:WaitForChild("Magnet")
  99. check = distCheck(magnet, coin)
  100. handle = magnet
  101. elseif Type.Value == "Magnet" then
  102. check = distCheck(handle, coin)
  103. if check < range*1.5 then--and rankCheck(coin, plr) then
  104. local multiplier2 = petboost.CoinBoost.Value
  105. local worth
  106. if purchases.DoubleCoins.Value then
  107. worth = coin.Name+multiplier2 * multiplier *2
  108. else
  109. worth = coin.Name+multiplier2 * multiplier
  110. end
  111.  
  112. coins.Value = coins.Value + worth
  113. coin.Name = "Claimed"
  114. local tween = ts:Create(coin, tweenInfo, {Position = handle.Position, Transparency = 1.25})
  115. tween:Play()
  116. wait(.15)
  117. coin:Destroy()
  118. wait(.05)
  119. collecting = collecting-1
  120. end
  121. end
  122. end
  123.  
  124. --coroutine.wrap(function()
  125. while wait(.07) do
  126. local fold = coins[val.Value]
  127. coinTable = fold:GetChildren()
  128. if humanoid.Health>0 and root and tool.Parent == char then
  129. for i = 1,#coinTable do
  130. if coinTable[i] then
  131. if coinTable[i].Name ~= "Claimed" and returnDistance(handle, coinTable[i]) < range and not backpackHandler:IsFull(plr) and tool.Parent == char and collecting < collectmax then --and rankCheck(coinTable[i], plr) and not backpackHandler:IsFull(plr) then
  132. local beam = Instance.new("Beam", handle)
  133. beam.CurveSize0 = 2
  134. beam.CurveSize1 = 2
  135. collecting = collecting + 1
  136. beam.FaceCamera = true
  137. beam.Color = ColorSequence.new(color, color)
  138. beam.Segments = 5
  139. beam.Width0 = 1
  140. beam.Width1 = 1
  141. local attach = Instance.new("Attachment", handle)
  142. beam.Attachment0 = attach
  143. beam.Attachment1 = coinTable[i].Attachment
  144. grabEvent:FireServer(coinTable[i].Name, tool) -- don't hurt yourself.
  145. coroutine.wrap(function()
  146. grab(coinTable[i])
  147. end)()
  148. table.remove(coinTable, i)
  149. debris:AddItem(beam, .2)
  150. debris:AddItem(attach, .2)
  151. end
  152. end
  153. end
  154. end
  155. end
  156. --end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement