Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local TweenService = game:GetService("TweenService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RunService = game:GetService("RunService")
- local player = Players.LocalPlayer
- local remotes = ReplicatedStorage:WaitForChild("Remotes")
- local despawnedDrops = ReplicatedStorage:WaitForChild("DespawnedDrops")
- local playersFolder = workspace.Players
- local drops = workspace.Drops
- for _, drop in ipairs(drops:GetDescendants()) do
- if drop:IsA("Model") then
- drop.CurrentPoints.Value = drop.MaxPoints.Value
- drop.ClickDetector.MouseClick:Connect(function(player)
- local currentPlayerPets = playersFolder[player.Name]:GetChildren()
- if #currentPlayerPets > 0 then
- if player.Areas:FindFirstChild(drop.Parent.Name) then
- for _, pet in pairs(currentPlayerPets) do
- if pet.Attack.Value == drop.PrimaryPart then
- pet.Attack.Value = nil
- else
- pet.Attack.Value = drop.PrimaryPart
- end
- end
- end
- end
- end)
- end
- end
- local function destroyDrop(drop)
- task.spawn(function()
- local oldParent = drop.Parent
- drop.Parent = despawnedDrops
- wait(4)
- drop.CurrentPoints.Value = drop.MaxPoints.Value
- drop.Parent = oldParent
- end)
- end
- local function updateDamage()
- local playerPets = playersFolder[player.Name]:GetChildren()
- for _, pet in ipairs(playerPets) do
- local attackValue = pet.Attack.Value
- if attackValue then
- local drop = attackValue.Parent
- local currentPoints = drop.CurrentPoints
- currentPoints.Value = math.max(currentPoints.Value - pet.Damage.Value, 0)
- if currentPoints.Value == 0 then
- for _, pet in pairs(playerPets) do
- pet.Attack.Value = nil
- end
- destroyDrop(drop)
- end
- end
- end
- end
- local function updateDropDisplay()
- local drops = workspace:WaitForChild("Drops"):GetDescendants()
- for _, drop in pairs(drops) do
- if drop:IsA("Model") then
- local display = drop:FindFirstChild("Display")
- local bar = display.Background.Bar
- local displayText = display.Background.Amount
- displayText.Text = tostring(drop.CurrentPoints.Value)
- bar:TweenSize(
- UDim2.fromScale(drop.CurrentPoints.Value / drop.MaxPoints.Value, 1),
- Enum.EasingDirection.Out,
- Enum.EasingStyle.Sine,
- 0.3)
- end
- end
- end
- task.spawn(function()
- while task.wait(1) do
- updateDamage()
- updateDropDisplay()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement