Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pls = game:GetService("Players")
- local repstr = game:GetService("ReplicatedStorage")
- local debris = game:GetService("Debris")
- local ts = game:GetService("TweenService")
- local itemModule = require(repstr.ItemInformation)
- local mInfo = itemModule.MagnetInfo
- local rarityColors = itemModule.RarityInfo
- local tool = script.Parent
- local handle = tool.Handle
- local collecting = 0
- local collectmax = 5
- local animid = "rbxassetid://03486072754"
- local animc = Instance.new("Animation")
- animc.AnimationId = animid
- local plr = game.Players.LocalPlayer
- local val = plr:WaitForChild("Zone")
- repeat wait() until plr.Character
- local char = plr.Character
- local root = char:WaitForChild("HumanoidRootPart")
- local humanoid = char:WaitForChild("Humanoid")
- local hold = humanoid:LoadAnimation(animc)
- local eventsFolder = repstr.Events
- local magnetEvents = eventsFolder.MagnetEvents
- local backpackHandler = require(repstr.BackpackHandler)
- local grabEvent = magnetEvents.requestGrab
- local coins = workspace:WaitForChild("GlobalCoins")
- local coinTable = {}
- local tweenInfo = TweenInfo.new(
- .25, -- Time
- Enum.EasingStyle.Quad, -- EasingStyle
- Enum.EasingDirection.In, -- EasingDirection
- 1, -- RepeatCount (when less than zero the tween will loop indefinitely)
- false, -- Reverses (tween will reverse once reaching it's goal)
- 0 -- DelayTime
- )
- function rankCheck(coin, plr)
- if coin and plr then
- local stats = plr:WaitForChild("Stats")
- local tool = stats:WaitForChild("Tool")
- local coinRank = coin:WaitForChild("Rank")
- local plrRarity = mInfo[tool.Value][2]
- local plrRank = rarityColors[plrRarity][1]
- return (plrRank >= coinRank.Value)
- end
- end
- function returnDistance(p1, p2)
- if p1 and p2 then
- local dist = (p1.Position - p2.Position).magnitude
- return dist
- end
- end
- function distCheck(p1, p2)
- if p1 and p2 then
- local dist = (p1.Position - p2.Position).magnitude
- return dist
- end
- end
- tool.Equipped:connect(function()
- hold:Play()
- end)
- tool.Unequipped:connect(function()
- hold:Stop()
- end)
- local range = mInfo[tool.Name][1]
- local rarity = mInfo[tool.Name][2]
- local color = rarityColors[rarity][2].Color
- local multiplier = mInfo[tool.Name][3]
- function grab(coin)
- local stats = plr:WaitForChild("Stats")
- local coins = stats:WaitForChild("Coins")
- local backpack = stats:WaitForChild("Backpack")
- local petboost = plr:WaitForChild("PetBoosts")
- local purchases = plr:WaitForChild("Purchases")
- local Type = tool:WaitForChild("Type")
- local check
- if Type.Value == "Long" then
- local magnet = tool:WaitForChild("Magnet")
- check = distCheck(magnet, coin)
- handle = magnet
- elseif Type.Value == "Magnet" then
- check = distCheck(handle, coin)
- if check < range*1.5 then--and rankCheck(coin, plr) then
- local multiplier2 = petboost.CoinBoost.Value
- local worth
- if purchases.DoubleCoins.Value then
- worth = coin.Name+multiplier2 * multiplier *2
- else
- worth = coin.Name+multiplier2 * multiplier
- end
- coins.Value = coins.Value + worth
- coin.Name = "Claimed"
- local tween = ts:Create(coin, tweenInfo, {Position = handle.Position, Transparency = 1.25})
- tween:Play()
- wait(.15)
- coin:Destroy()
- wait(.05)
- collecting = collecting-1
- end
- end
- end
- --coroutine.wrap(function()
- while wait(.07) do
- local fold = coins[val.Value]
- coinTable = fold:GetChildren()
- if humanoid.Health>0 and root and tool.Parent == char then
- for i = 1,#coinTable do
- if coinTable[i] then
- 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
- local beam = Instance.new("Beam", handle)
- beam.CurveSize0 = 2
- beam.CurveSize1 = 2
- collecting = collecting + 1
- beam.FaceCamera = true
- beam.Color = ColorSequence.new(color, color)
- beam.Segments = 5
- beam.Width0 = 1
- beam.Width1 = 1
- local attach = Instance.new("Attachment", handle)
- beam.Attachment0 = attach
- beam.Attachment1 = coinTable[i].Attachment
- grabEvent:FireServer(coinTable[i].Name, tool) -- don't hurt yourself.
- coroutine.wrap(function()
- grab(coinTable[i])
- end)()
- table.remove(coinTable, i)
- debris:AddItem(beam, .2)
- debris:AddItem(attach, .2)
- end
- end
- end
- end
- end
- --end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement