Joriangames

Hit To Destroy Part

Jan 4th, 2024 (edited)
1,927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. --[[
  2. HOW TO MAKE HIT-TO-DESTROY Part!!! Roblox Studio Tutorial youtube.com/c/BloxianCode
  3. Tutorial: https://youtu.be/OjFsEDZEK5A?si=r4eGEbWWw_pHhmL4
  4.  
  5. Don't touch the model or script unless you know what you are doing
  6. Watch the video for more info https://youtu.be/OjFsEDZEK5A?si=r4eGEbWWw_pHhmL4
  7. ]]
  8.  
  9. local gr = Color3.fromRGB(56,255,12)
  10. local red = Color3.fromRGB(255,0,4)
  11. local canTouch = true
  12. local partH = 100
  13.  
  14. script.Parent.Touched:Connect(function(hit)
  15.     if hit.Parent.Name == "ClassicSword" and canTouch == true then
  16.         canTouch = false
  17.         partH = partH -10
  18.        
  19.         script.Parent.BillboardGui.TextLabel.Text = "Health: "..partH.."%"
  20.         script.Parent.BillboardGui.TextLabel.BackgroundColor3 = red:lerp(gr, partH / 100)
  21.        
  22.         if partH == 0 then
  23.             script.Parent.BillboardGui.TextLabel.Text = "Destroying..."
  24.             wait(2)
  25.             script.Parent:Destroy()
  26.         end
  27.        
  28.         wait(1)
  29.         canTouch = true
  30.     end
  31. end)
  32.  
Advertisement
Add Comment
Please, Sign In to add comment