Advertisement
xmaanzach

Sistema de Tala de Árboles

Jun 1st, 2019
4,584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. -- Created by xmaanzach
  2.  
  3. local Tronco = script.Parent.Tronco
  4. local Model = script.Parent
  5. local Backup = Model:Clone()
  6.  
  7. local leaves = {}
  8.  
  9. local Regenerar = true
  10. local RegenCooldown = 3
  11.  
  12. local debounce = false
  13. local fall = false
  14.  
  15. local ToolName = "Hacha"
  16. local Currency = "Madera"
  17. local Amount = 100
  18.  
  19. for _, child in pairs(script.Parent:GetChildren())do
  20. if child ~= script and child ~= Tronco and child:IsA("UnionOperation") or child:IsA("Part") then
  21. table.insert(leaves, child)
  22. end
  23. end
  24.  
  25. local function DestroyLeaves()
  26.  
  27. for hoja = 1, #leaves do
  28. leaves[hoja].Anchored = false
  29. leaves[hoja].CanCollide = false
  30. Tronco.Transparency = 1
  31. fall = true
  32. end
  33. end
  34.  
  35. Tronco.Touched:Connect(function(hit)
  36.  
  37. if hit.Parent.Name == ToolName then
  38. if not debounce and not fall then
  39. debounce = true
  40. local Player = game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
  41.  
  42. local leader = Player.leaderstats:FindFirstChild(Currency)
  43.  
  44. leader.Value = leader.Value + Amount
  45. DestroyLeaves()
  46. end
  47. end
  48. wait(3)
  49. debounce = false
  50. end)
  51.  
  52. while wait() do
  53. if fall then
  54. wait(0.5)
  55. Model:Destroy()
  56. if fall and Regenerar then
  57. wait(RegenCooldown)
  58. Backup.Parent = workspace
  59. Backup:MakeJoints()
  60. break
  61. end
  62. end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement