Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- model = script.Parent.Parent:FindFirstChildWhichIsA("Model")
- backup = model:clone()
- local text = script.Parent.BillboardGui.TextLabel
- local button = script.Parent
- local pushPart = script.Parent.Parent.WipePart
- local stone = script.Parent.Parent.Stone
- local deleteBool = false
- local TweenService = game:GetService("TweenService")
- local tweenInfo = TweenInfo.new(
- 1,
- Enum.EasingStyle.Sine,
- Enum.EasingDirection.InOut,
- 0,
- true,
- 0
- )
- local pushGoal = pushPart.CFrame + Vector3.new(0,0,-50)
- local pushTween = TweenService:Create(pushPart, tweenInfo, {CFrame = pushGoal})
- local function activateButton(touched)
- touched.Value = true
- local duration = 5
- button.BrickColor = BrickColor.new("Black")
- pushPart.CanCollide = true
- pushPart.Transparency = 0
- pushTween:Play()
- deleteBool = true
- task.wait(2)
- pushPart.CanCollide = false
- pushPart.Transparency = 0.5
- deleteBool = false
- model = backup:clone()
- model.Parent = game.Workspace
- local timer = duration
- while timer > 0 do
- print(timer)
- text.Text = "COOLDOWN: "..timer
- task.wait(1)
- timer = timer - 1
- end
- button.BrickColor = BrickColor.new("Fossil")
- touched.Value = false
- text.Text = "RESPAWN CAR"
- end
- button.Touched:Connect(function(otherPart)
- local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
- local touched = button:FindFirstChild("Touched")
- if humanoid and touched and touched.Value == false then
- activateButton(touched)
- end
- end)
- pushPart.Touched:Connect(function(otherPart)
- if not otherPart or not otherPart.Parent then
- return
- end
- local modelToDestroy = nil
- local currentAncestor = otherPart.Parent -- Start with the immediate parent of the touched part
- while currentAncestor and currentAncestor ~= game do
- if currentAncestor:IsA("Model") then
- local vehicleTag = currentAncestor:FindFirstChild("Vehicle")
- if vehicleTag and vehicleTag:IsA("BoolValue") then
- modelToDestroy = currentAncestor
- break
- end
- end
- if not currentAncestor.Parent then
- break
- end
- currentAncestor = currentAncestor.Parent
- end
- if modelToDestroy and deleteBool then
- modelToDestroy:Destroy()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement