Advertisement
Guest User

Code

a guest
May 29th, 2025
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. model = script.Parent.Parent:FindFirstChildWhichIsA("Model")
  2.  
  3. backup = model:clone()
  4.  
  5. local text = script.Parent.BillboardGui.TextLabel
  6.  
  7. local button = script.Parent
  8.  
  9. local pushPart = script.Parent.Parent.WipePart
  10.  
  11. local stone = script.Parent.Parent.Stone
  12.  
  13.  
  14.  
  15. local deleteBool = false
  16.  
  17.  
  18. local TweenService = game:GetService("TweenService")
  19.  
  20. local tweenInfo = TweenInfo.new(
  21. 1,
  22. Enum.EasingStyle.Sine,
  23. Enum.EasingDirection.InOut,
  24. 0,
  25. true,
  26. 0
  27.  
  28. )
  29.  
  30. local pushGoal = pushPart.CFrame + Vector3.new(0,0,-50)
  31.  
  32. local pushTween = TweenService:Create(pushPart, tweenInfo, {CFrame = pushGoal})
  33.  
  34.  
  35.  
  36.  
  37.  
  38. local function activateButton(touched)
  39.  
  40.  
  41.  
  42. touched.Value = true
  43.  
  44.  
  45. local duration = 5
  46.  
  47. button.BrickColor = BrickColor.new("Black")
  48.  
  49.  
  50.  
  51. pushPart.CanCollide = true
  52. pushPart.Transparency = 0
  53. pushTween:Play()
  54. deleteBool = true
  55.  
  56. task.wait(2)
  57. pushPart.CanCollide = false
  58. pushPart.Transparency = 0.5
  59. deleteBool = false
  60.  
  61. model = backup:clone()
  62. model.Parent = game.Workspace
  63.  
  64.  
  65.  
  66. local timer = duration
  67.  
  68. while timer > 0 do
  69. print(timer)
  70. text.Text = "COOLDOWN: "..timer
  71. task.wait(1)
  72. timer = timer - 1
  73. end
  74.  
  75.  
  76.  
  77. button.BrickColor = BrickColor.new("Fossil")
  78.  
  79.  
  80. touched.Value = false
  81. text.Text = "RESPAWN CAR"
  82. end
  83.  
  84.  
  85. button.Touched:Connect(function(otherPart)
  86. local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
  87. local touched = button:FindFirstChild("Touched")
  88.  
  89.  
  90. if humanoid and touched and touched.Value == false then
  91.  
  92.  
  93.  
  94. activateButton(touched)
  95. end
  96.  
  97.  
  98.  
  99.  
  100. end)
  101.  
  102.  
  103. pushPart.Touched:Connect(function(otherPart)
  104.  
  105. if not otherPart or not otherPart.Parent then
  106. return
  107. end
  108.  
  109. local modelToDestroy = nil
  110. local currentAncestor = otherPart.Parent -- Start with the immediate parent of the touched part
  111.  
  112.  
  113. while currentAncestor and currentAncestor ~= game do
  114.  
  115. if currentAncestor:IsA("Model") then
  116.  
  117. local vehicleTag = currentAncestor:FindFirstChild("Vehicle")
  118. if vehicleTag and vehicleTag:IsA("BoolValue") then
  119. modelToDestroy = currentAncestor
  120. break
  121. end
  122. end
  123.  
  124.  
  125. if not currentAncestor.Parent then
  126. break
  127. end
  128. currentAncestor = currentAncestor.Parent
  129. end
  130.  
  131.  
  132. if modelToDestroy and deleteBool then
  133.  
  134. modelToDestroy:Destroy()
  135.  
  136. end
  137. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement