Advertisement
Cassimus

Drop

Oct 27th, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local TweenService = game:GetService("TweenService")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4. local RunService = game:GetService("RunService")
  5.  
  6. local player = Players.LocalPlayer
  7.  
  8. local remotes = ReplicatedStorage:WaitForChild("Remotes")
  9. local despawnedDrops = ReplicatedStorage:WaitForChild("DespawnedDrops")
  10.  
  11. local playersFolder = workspace.Players
  12. local drops = workspace.Drops
  13.  
  14.  
  15. for _, drop in pairs(drops:GetDescendants()) do
  16. if drop:IsA("Model") then
  17. drop.CurrentPoints.Value = drop.MaxPoints.Value
  18.  
  19. drop.ClickDetector.MouseClick:Connect(function(player)
  20. local currentPlayerPets = playersFolder[player.Name]:GetChildren()
  21. if #currentPlayerPets > 0 then
  22. if player.Areas:FindFirstChild(drop.Parent.Name) then
  23. for _, pet in pairs(currentPlayerPets) do
  24. if pet.Attack.Value == drop.PrimaryPart then
  25. pet.Attack.Value = nil
  26. else
  27. pet.Attack.Value = drop.PrimaryPart
  28. end
  29. end
  30. end
  31. end
  32. end)
  33. end
  34. end
  35.  
  36. local function destroyDrop(drop)
  37. task.spawn(function()
  38. local oldParent = drop.Parent
  39. drop.Parent = despawnedDrops
  40.  
  41. wait(4)
  42.  
  43. drop.CurrentPoints.Value = drop.MaxPoints.Value
  44. drop.Parent = oldParent
  45. end)
  46. end
  47.  
  48. local function updateDamage()
  49. local playerPets = playersFolder[player.Name]:GetChildren()
  50. for _, pet in ipairs(playerPets) do
  51. local attackValue = pet.Attack.Value
  52. if attackValue then
  53. local drop = attackValue.Parent
  54. local currentPoints = drop.CurrentPoints
  55. currentPoints.Value = math.max(currentPoints.Value - pet.Damage.Value, 0)
  56. if currentPoints.Value == 0 then
  57. for _, pet in pairs(playerPets) do
  58. pet.Attack.Value = nil
  59. end
  60. for i, item in pairs(drop:GetChildren()) do
  61. if item.Name == "Reward" then
  62. remotes.Bank:FireServer("+", item.Value, item.Amount.Value)
  63. end
  64. end
  65. destroyDrop(drop)
  66. end
  67. end
  68. end
  69. end
  70.  
  71. local function updateDropDisplay()
  72. local drops = workspace:WaitForChild("Drops"):GetDescendants()
  73.  
  74. for _, drop in ipairs(drops) do
  75. if drop:IsA("Model") then
  76. local display = drop:FindFirstChild("Display")
  77. local bar = display.Background.Bar
  78. local displayText = display.Background.Amount
  79.  
  80. displayText.Text = tostring(drop.CurrentPoints.Value)
  81.  
  82. bar:TweenSize(
  83. UDim2.fromScale(drop.CurrentPoints.Value / drop.MaxPoints.Value, 1),
  84. Enum.EasingDirection.Out,
  85. Enum.EasingStyle.Sine,
  86. 0.3)
  87. end
  88. end
  89. end
  90.  
  91. task.spawn(function()
  92. while task.wait(1) do
  93. updateDamage()
  94. updateDropDisplay()
  95. end
  96. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement