Advertisement
HowToRoblox

FireworkLauncher

Apr 7th, 2020
1,301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. local tweenService = game:GetService("TweenService")
  2.  
  3. local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut)
  4.  
  5.  
  6. local clickDetector = script.Parent.ClickDetector
  7.  
  8.  
  9. local function propertyOfChildren(parent, property, value)
  10.    
  11.     for i, child in pairs(parent:GetChildren()) do 
  12.        
  13.         if child.ClassName == "Part" or child.ClassName == "MeshPart" then
  14.            
  15.             child[property] = value
  16.         end
  17.     end
  18. end
  19.  
  20.  
  21. clickDetector.MouseClick:Connect(function()
  22.    
  23.    
  24.     clickDetector:Destroy()
  25.    
  26.    
  27.     script.Parent.ParticlesPart.LaunchParticles.Enabled = true
  28.    
  29.    
  30.     local cframeVal = Instance.new("CFrameValue")
  31.    
  32.     cframeVal.Value = script.Parent:GetPrimaryPartCFrame()
  33.    
  34.    
  35.     cframeVal:GetPropertyChangedSignal("Value"):Connect(function()
  36.        
  37.         script.Parent:SetPrimaryPartCFrame(cframeVal.Value)
  38.     end)
  39.    
  40.    
  41.     local tweenShake = tweenService:Create(cframeVal, tweenInfo, {Value = script.Parent.PrimaryPart.CFrame * CFrame.Angles(math.rad(math.random(10, 20)), math.rad(math.random(10, 20)), 0)})  
  42.     tweenShake:Play()  
  43.    
  44.     tweenShake.Completed:Wait()
  45.    
  46.    
  47.     local tweenShakeReturn = tweenService:Create(cframeVal, tweenInfo, {Value = script.Parent.PrimaryPart.CFrame * CFrame.Angles(math.rad(math.random(-20, -10)), math.rad(math.random(-20, -10)), 0)})
  48.     tweenShakeReturn:Play()
  49.    
  50.     tweenShakeReturn.Completed:Wait()
  51.    
  52.    
  53.     propertyOfChildren(script.Parent, "Anchored", false)
  54.    
  55.    
  56.     local bodyPos = Instance.new("BodyVelocity")
  57.    
  58.     bodyPos.Velocity = Vector3.new(0, 3000, 0)
  59.    
  60.     bodyPos.Parent = script.Parent.MainBody
  61.    
  62.    
  63.     script.Parent.ParticlesPart.LaunchSound:Play()
  64.    
  65.    
  66.     wait(0.5)
  67.    
  68.    
  69.     script.Parent.ParticlesPart.LaunchSound:Stop()
  70.    
  71.    
  72.     bodyPos:Destroy()
  73.    
  74.     propertyOfChildren(script.Parent, "Anchored", true)
  75.    
  76.    
  77.     propertyOfChildren(script.Parent, "Transparency", 1)
  78.    
  79.    
  80.     script.Parent.ExplodeSound:Play()
  81.    
  82.    
  83.     script.Parent.ParticlesPart.LaunchParticles.Enabled = false
  84.    
  85.     script.Parent.MainBody.ExplodeParticles.Enabled = true
  86.    
  87.    
  88.     wait(3)
  89.    
  90.    
  91.     script.Parent:Destroy()
  92. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement