OOFBOI574

Health Pickup/Healing Station Script (Roblox)

Dec 1st, 2021 (edited)
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local MAX_HEALTH = 100
  2. local ENABLED_TRANSPARENCY = 0.4
  3. local DISABLED_TRANSPARENCY = 0.9
  4. local COOLDOWN = 20
  5.  
  6. local healthPickupsFolder = workspace:WaitForChild("HealthPickups")
  7. local healthPickups = healthPickupsFolder:GetChildren()
  8.  
  9. local function onTouchHealthPickup(otherPart, healthPickup)
  10.     if healthPickup:GetAttribute("Enabled") then
  11.         local character = otherPart.Parent
  12.         local humanoid = character:FindFirstChildWhichIsA("Humanoid")
  13.         if humanoid then
  14.             humanoid.Health = MAX_HEALTH
  15.             healthPickup.Transparency = DISABLED_TRANSPARENCY
  16.             healthPickup:SetAttribute("Enabled", false)
  17.             wait(COOLDOWN)
  18.             healthPickup.Transparency = ENABLED_TRANSPARENCY
  19.             healthPickup:SetAttribute("Enabled", true)
  20.         end
  21.     end
  22. end
  23.  
  24. for _, healthPickup in ipairs(healthPickups) do
  25.     healthPickup:SetAttribute("Enabled", true)
  26.     healthPickup.Touched:Connect(function(otherPart)
  27.         onTouchHealthPickup(otherPart, healthPickup)
  28.     end)
  29. end
RAW Paste Data Copied