Advertisement
vibrantsinger423

sendey

Aug 12th, 2022 (edited)
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.75 KB | None | 0 0
  1. local player = game.Players.VarixDog
  2. local animationActive = false
  3. local animationEnded = false
  4. local animationStarted = false
  5. local animationTimer = 0
  6. local projectileID = 0
  7. local projectiles = {}
  8. local explosionSoundIDs = {4474833664, 142070127, 262562442, 5801257793}
  9. local mousePos = Vector3.new(0,0,0)
  10. local localRemote = Instance.new("RemoteEvent",player.Character)
  11. localRemote.Name = "mouse getter 9000"
  12. NLS([[
  13. local player = game:GetService("Players").VarixDog
  14. local remote = player.Character["mouse getter 9000"]
  15. function swait()
  16. game:GetService("RunService").Heartbeat:Wait()
  17. end
  18. while true do
  19. swait()
  20. remote:FireServer(player:GetMouse().Hit.Position)
  21. end
  22. ]],player.Character)
  23. localRemote.OnServerEvent:Connect(function(player, mousepos)
  24. mousePos = mousepos
  25. end)
  26.  
  27. function createTorsoPartWithJoint(size, colour, material, motorOffset, motorAngle, name, shape, cfAngle)
  28. local backPart = Instance.new("Part", player.Character.Torso)
  29. backPart.CanCollide = false
  30. backPart.Name = name
  31. backPart.Size = size
  32. backPart.Material = material
  33. backPart.Color = colour
  34. if shape == nil then
  35. shape = Enum.PartType.Cylinder
  36. end
  37. backPart.Shape = shape
  38. --================ • Welding to torso • ===================--
  39. local weld = Instance.new("Motor6D", player.Character.Torso)
  40. weld.Part0 = player.Character.Torso
  41. weld.Name = name
  42. weld.Part1 = backPart
  43. weld.CurrentAngle = motorAngle
  44. if cfAngle then
  45. weld.C0 = CFrame.new(motorOffset.x, motorOffset.y, motorOffset.z) * cfAngle
  46. else
  47. weld.C0 = CFrame.new(motorOffset.x, motorOffset.y, motorOffset.z)
  48. end
  49. return backPart
  50. end
  51.  
  52. function createBack()
  53. local decoCF = CFrame.new(0,2.7/2, 1.25)
  54. local decoAngle1 = CFrame.fromEulerAnglesXYZ(0, 0, math.rad(90))
  55. local decoAngle2 = CFrame.fromEulerAnglesXYZ(0, math.rad(45), math.rad(90))
  56. local decoAngle3 = CFrame.fromEulerAnglesXYZ(0, math.rad(90), math.rad(90))
  57. local decoAngle4 = CFrame.fromEulerAnglesXYZ(0, math.rad(135), math.rad(90))
  58. --====================== • MAIN PART BEHIND TORSO • ========================--
  59. local part1 = createTorsoPartWithJoint(Vector3.new(3,2.5,2.5), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, Vector3.new(0,0,1.25), 1.5708, "MainBack")
  60. --========================= • PARTS THAT SURROUND MAIN PART • ==================================--
  61. local part2 = createTorsoPartWithJoint(Vector3.new(0.3,2.7,2.7),Color3.fromRGB(163, 162, 165) , Enum.Material.DiamondPlate, Vector3.new(0,1.25,1.25), 1.5708, "MainRim1")
  62. local part3 = createTorsoPartWithJoint(Vector3.new(0.3,2.7,2.7),Color3.fromRGB(163, 162, 165) , Enum.Material.DiamondPlate, Vector3.new(0,-1.25,1.25), 1.5708, "MainRim2")
  63. --======================== • TOP PART OF BARREL • ==============================--
  64. local part4 = createTorsoPartWithJoint(Vector3.new(1.4,2.3,2.3), Color3.fromRGB(99, 95, 98), Enum.Material.DiamondPlate, Vector3.new(0,2.7/2,1.25), 1.5708, "BeforeBarrel")
  65. local part5 = createTorsoPartWithJoint(Vector3.new(0.01,2.1,2.1), Color3.fromRGB(0 ,0 ,0), Enum.Material.SmoothPlastic, Vector3.new(0,2.7/2+1.4/2,1.25), 1.5708, "Hole")
  66. --============================== • TOP BARREL SURROUNDING PARTS • ===============================--
  67. local part6 = createTorsoPartWithJoint(Vector3.new(2.35, 1.395, 0.2), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, decoCF, 1.5708, "Deco1", Enum.PartType.Block, decoAngle1)
  68. local part7 = createTorsoPartWithJoint(Vector3.new(2.35, 1.395, 0.2), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, decoCF, 1.5708, "Deco2", Enum.PartType.Block, decoAngle2)
  69. local part8 = createTorsoPartWithJoint(Vector3.new(2.35, 1.395, 0.2), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, decoCF, 1.5708, "Deco3", Enum.PartType.Block, decoAngle3)
  70. local part9 = createTorsoPartWithJoint(Vector3.new(2.35, 1.395, 0.2), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, decoCF, 1.5708, "Deco4", Enum.PartType.Block, decoAngle4)
  71. --======== • CANNON SECTION • =====================--
  72. local cannonP = Instance.new("Part", player.Character.Torso)
  73. cannonP.CanCollide = false
  74. cannonP.Name = "CannonPart"
  75. cannonP.Size = Vector3.new(2.128, 3.684, 2.128)
  76. cannonP.Color = Color3.fromRGB(99, 95, 98)
  77. local cannonMesh = Instance.new("SpecialMesh", cannonP)
  78. cannonMesh.MeshId = "rbxassetid://1418967188"
  79. cannonMesh.Scale = Vector3.new(0.9,0.35,0.9)
  80. local cannonM = Instance.new("Motor6D", player.Character.Torso)
  81. cannonM.Part0 = player.Character.Torso
  82. cannonM.Name = "Cannon"
  83. cannonM.Part1 = cannonP
  84. cannonM.CurrentAngle = 0
  85. cannonM.C0 = CFrame.new(0,2.7/2+1.5, 1.25)
  86. end
  87. function swait()
  88. game:GetService("RunService").Heartbeat:Wait()
  89. end
  90.  
  91. function cannonRecoil(strength)
  92. local cannon = player.Character.Torso.Cannon
  93. if cannon ~= nil then
  94. cannon.C0 = cannon.C0:lerp(CFrame.new(0 ,2.7/2-1, 1.25), strength)
  95. end
  96. end
  97. function cannonReturn(strength)
  98. local cannon = player.Character.Torso.Cannon
  99. if cannon ~= nil then
  100. cannon.C0 = cannon.C0:lerp(CFrame.new(0,2.7/2+1.5, 1.25), strength)
  101. end
  102. end
  103. wait(1)
  104. createBack()
  105.  
  106. function animateCannon()
  107. if animationTimer > 0 then
  108. cannonRecoil(0.2)
  109. elseif animationTimer < 0 then
  110. cannonReturn(0.01)
  111. end
  112. end
  113. function lerp(a, b, c)
  114. return a + (b - a) * c
  115. end
  116. function radialDamage(position, radius, damage)
  117. for i,obj in pairs(workspace:GetChildren()) do
  118. if obj:IsA("Model") then
  119. local model = obj
  120. local hitHum = model:FindFirstChildWhichIsA("Humanoid")
  121. local modelMain = model.PrimaryPart
  122. if hitHum then
  123. local mag = (modelMain.Position - position).Magnitude
  124. if mag < radius then
  125. hitHum:TakeDamage(damage)
  126. end
  127. end
  128. end
  129. end
  130. end
  131. function radialBreakJoints(position, radius)
  132. local part = Instance.new("Part",workspace); part.Size = Vector3.new(1,1,1); part.Anchored = true; part.CanCollide = false; part.Position = Vector3.new(radius,0,0) + position
  133. local part2 = Instance.new("Part",workspace); part2.Size = Vector3.new(1,1,1); part2.Anchored = true; part2.CanCollide = false; part2.Position = Vector3.new(-radius,0,0) + position
  134. local part3 = Instance.new("Part",workspace); part3.Size = Vector3.new(1,1,1); part3.Anchored = true; part3.CanCollide = false; part3.Position = Vector3.new(0,0,radius) + position
  135. local part4 = Instance.new("Part",workspace); part4.Size = Vector3.new(1,1,1); part4.Anchored = true; part4.CanCollide = false; part4.Position = Vector3.new(0,0,-radius) + position
  136. --============== • DETECT HUMANOIDS IN MODELS • ===================--
  137. for i,obj in pairs(workspace:GetChildren()) do
  138. if obj:IsA("Model") and obj.PrimaryPart then
  139. local model = obj
  140. local modelMain = model.PrimaryPart
  141. local mag = (modelMain.Position - position).Magnitude
  142. if mag < radius then
  143. local modelParts = model:GetChildren()
  144. for i,objM in pairs(modelParts) do
  145. if objM:IsA("BasePart") then
  146. objM:BreakJoints()
  147. end
  148. end
  149. end
  150. --============ • CHECK THEY ARENT HIDDEN IN ANOTHER MODEL • ============--
  151. elseif obj:IsA("Model") and not obj.PrimaryPart then
  152. local model = obj
  153. local checkForNextModel = model:FindFirstChildWhichIsA("Model")
  154. if checkForNextModel then
  155. local model2Main = nil
  156. if checkForNextModel.PrimaryPart == nil then
  157. if checkForNextModel:FindFirstChild("Torso") ~= nil then
  158. model2Main = checkForNextModel:FindFirstChild("Torso")
  159. end
  160. elseif checkForNextModel.PrimaryPart ~= nil then
  161. model2Main = checkForNextModel.PrimaryPart
  162. end
  163. local mag = (model2Main.Position - position).Magnitude
  164. if mag < radius then
  165. local mode2Parts = checkForNextModel:GetChildren()
  166. for i,objM in pairs(mode2Parts) do
  167. if objM:IsA("BasePart") then
  168. objM:BreakJoints()
  169. end
  170. end
  171. end
  172. end
  173. end
  174. end
  175. end
  176. function cannonFireMissileSwarm()
  177. animationTimer = 0.5
  178. for i = 1,10 do
  179. local missile = Instance.new("Part", workspace)
  180.  
  181. end
  182. end
  183. --Get nuke Velocity Direction
  184. --Get Nuke Direction To Target
  185. --Get Angle between (Nuke Velocity Direction * Nuke Target Position)
  186. --Rotate Nukes velocity at a certain amount to get to that angle
  187. function cannonFireNuke(mouseMode, worldCollides, targetPart)
  188. local nukeTurnRate = 3
  189. projectileID += 1
  190. local projectileIndex = projectileID
  191. local projectileOrigin = player.Character.Torso.CannonPart.Position + Vector3.new(0, 3.684/2, 0)
  192. local bezierMidpoint = projectileOrigin + Vector3.new(0,30,0)
  193. local projectileEnd = mousePos
  194. local nukeDistance = (projectileOrigin - projectileEnd).Magnitude
  195. local nukeCollided = false
  196. local nukeAtTargetHeight = false
  197. local nukeTargetHeight = 50
  198. animationTimer = 0.6
  199.  
  200. local nuke = Instance.new("Part",workspace)
  201. nuke.Name = "nukeMainPart"
  202. nuke.CanCollide = true
  203. nuke.Anchored = true
  204. nuke.Position = projectileOrigin
  205. nuke.Size = Vector3.new(1.667, 1.667, 5.1)
  206. nuke.Orientation = Vector3.new(90, -90, 0)
  207. local mesh = Instance.new("SpecialMesh",nuke)
  208. mesh.Scale = Vector3.new(0.15, 0.15, 0.1)
  209. mesh.MeshId = "rbxassetid://4402080069"
  210. mesh.TextureId = "rbxassetid://4402080160"
  211. local sound = Instance.new("Sound",nuke)
  212. sound.SoundId = "rbxassetid://7615746490"
  213. sound.Volume = 1
  214. sound:Play()
  215. --=============================== • NUKE THRUSTER PARTICLE EMITTERS • =======================================--
  216.  
  217. local afterAir = Instance.new("ParticleEmitter", nuke)
  218. local Thruster = Instance.new("ParticleEmitter", nuke)
  219. local nukeAfterThrustSeq = {ColorSequenceKeypoint.new(0, Color3.fromRGB(68,68,68)), ColorSequenceKeypoint.new(1, Color3.fromRGB(0,0,0))}
  220. local nukeThrusterSeq = {ColorSequenceKeypoint.new(0, Color3.fromRGB(213,128,10)), ColorSequenceKeypoint.new(0.5, Color3.fromRGB(159,53,0)), ColorSequenceKeypoint.new(0.6, Color3.fromRGB(61,57,57)), ColorSequenceKeypoint.new(1, Color3.fromRGB(85,85,85))}
  221. local nukeAfterThrustSizeSeq = {NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(0.04, 0), NumberSequenceKeypoint.new(1, 10)}
  222. local nukeThrusterSizeSeq = {NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(0.05,0), NumberSequenceKeypoint.new(0.2, 2.5), NumberSequenceKeypoint.new(0.7, 0), NumberSequenceKeypoint.new(1,0)}
  223. local nukeAfterThrustTransparencySeq = {NumberSequenceKeypoint.new(0,0.25), NumberSequenceKeypoint.new(0.75, 0.3), NumberSequenceKeypoint.new(1, 1)}
  224. local nukeThrusterTransparencySeq = {NumberSequenceKeypoint.new(0,0.25), NumberSequenceKeypoint.new(0.9, 0.35), NumberSequenceKeypoint.new(1,1)}
  225. afterAir.Color = ColorSequence.new(nukeAfterThrustSeq)
  226. Thruster.Color = ColorSequence.new(nukeThrusterSeq)
  227. afterAir.LightEmission = 1
  228. Thruster.LightEmission = 1
  229. afterAir.LightInfluence = 1
  230. Thruster.LightInfluence = 1
  231. afterAir.Size = NumberSequence.new(nukeAfterThrustSizeSeq)
  232. Thruster.Size = NumberSequence.new(nukeAfterThrustSizeSeq)
  233. afterAir.Texture = "http://www.roblox.com/asset/?id=528256032"
  234. Thruster.Texture = "http://www.roblox.com/asset/?id=528256032"
  235. afterAir.Transparency = NumberSequence.new(nukeAfterThrustTransparencySeq)
  236. Thruster.Transparency = NumberSequence.new(nukeThrusterTransparencySeq)
  237. afterAir.ZOffset = -1
  238. Thruster.ZOffset = 0
  239. afterAir.Name = "AirParticles"
  240. Thruster.Name = "Thruster"
  241. afterAir.EmissionDirection = "Back"
  242. Thruster.EmissionDirection = "Back"
  243. afterAir.Enabled = true
  244. Thruster.Enabled = true
  245. afterAir.Lifetime = NumberRange.new(1,1)
  246. Thruster.Lifetime = NumberRange.new(1,1)
  247. afterAir.Rate = 10
  248. Thruster.Rate = 10
  249. afterAir.Speed = NumberRange.new(60,60)
  250. Thruster.Speed = NumberRange.new(60,60)
  251. local nukeInfo = {
  252. part = nuke,
  253. ID = projectileID,
  254. originPosition = projectileOrigin,
  255. worldCollisions = worldCollides,
  256. targetPart = nil,
  257. followsMouse = true,
  258. recoilSecconds = 0.6,
  259. targetHeight = 50,
  260. turnSpeed = nukeTurnRate,
  261. atTargetHeight = false,
  262. canExplode = false,
  263. collision = false
  264. }
  265. table.insert(projectiles,1,nukeInfo)
  266. end
  267.  
  268. function projectileUpdate()
  269. for index,dict in ipairs(projectiles) do
  270. --spawn(function()
  271. --print(index)
  272. local nuke = dict["part"]
  273. local projectileOrigin = dict["originPosition"]
  274. local nukeTargetHeight = dict["targetHeight"]
  275. local nukeAtTargetHeight = dict["atTargetHeight"]
  276. local nukeTurnRate = dict["turnSpeed"]
  277. local nukeCollided = dict["collision"]
  278. local currentNukeIndex = dict["ID"]
  279. --=================================== • Reach Target Height • ================================--
  280. if nuke.Position.Y < (projectileOrigin.Y+nukeTargetHeight) and nukeAtTargetHeight == false then
  281. nuke.Position = nuke.Position + nuke.CFrame.LookVector * 2
  282. elseif nuke.Position.Y > (projectileOrigin.Y+nukeTargetHeight) then
  283. dict["atTargetHeight"] = true
  284. end
  285. --====== • Optimisation • ======--
  286. if dict["collision"] == false then
  287. --==================================== • Calculations • =======================================--
  288. local touchedParts = nuke:GetTouchingParts()
  289. local touchedPartValid = false
  290. for index, part in ipairs(touchedParts) do
  291. if not tostring(part.Name) == "nukeMainPart" or part.Parent ~= player.Character then
  292. --print("Collided With Non-Missile / Character Part")
  293. --dict["collision"] = true
  294. end
  295. end
  296. --print(touchedParts)
  297. if dict["collision"] == true then
  298. spawn(function()
  299. dict["collision"] = true
  300. nuke.Transparency = 1
  301. nuke.CanCollide = false
  302. for i,obj in pairs(nuke:GetChildren()) do
  303. if obj:IsA("ParticleEmitter") then
  304. obj.Enabled = false
  305. end
  306. end
  307. local collisionPosition = Vector3.new(nuke.Position.X, nuke.Position.Y-1, nuke.Position.Z)
  308. local particlePart = Instance.new("Part",workspace)
  309. particlePart.Anchored = true
  310. particlePart.CanCollide = false
  311. particlePart.Size =- Vector3.new(0.1, 0.1, 0.1)
  312. particlePart.Transparency = 1
  313. particlePart.Position = collisionPosition
  314. game:GetService("Debris"):AddItem(particlePart, 3)
  315. local ExplosionSphere = Instance.new("ParticleEmitter", particlePart)
  316. local ExplosionRing = Instance.new("ParticleEmitter", particlePart)
  317. local nukeAfterThrustSeq = {ColorSequenceKeypoint.new(0, Color3.fromRGB(106,106,106)), ColorSequenceKeypoint.new(1, Color3.fromRGB(106,106,106))}
  318. local nukeThrusterSeq = {ColorSequenceKeypoint.new(0, Color3.fromRGB(135,135,135)), ColorSequenceKeypoint.new(1, Color3.fromRGB(135,135,135))}
  319. local nukeAfterThrustSizeSeq = {NumberSequenceKeypoint.new(0, 5), NumberSequenceKeypoint.new(1, 10)}
  320. local nukeThrusterSizeSeq = {NumberSequenceKeypoint.new(0,5), NumberSequenceKeypoint.new(1, 10)}
  321. local nukeAfterThrustTransparencySeq = {NumberSequenceKeypoint.new(0,0.25), NumberSequenceKeypoint.new(1, 1)}
  322. local nukeThrusterTransparencySeq = {NumberSequenceKeypoint.new(0,0.25), NumberSequenceKeypoint.new(1,1)}
  323. ExplosionSphere.Color = ColorSequence.new(nukeAfterThrustSeq)
  324. ExplosionRing.Color = ColorSequence.new(nukeThrusterSeq)
  325. ExplosionSphere.LightEmission = 0
  326. ExplosionRing.LightEmission = 0
  327. ExplosionSphere.LightInfluence = 1
  328. ExplosionRing.LightInfluence = 1
  329. ExplosionSphere.Size = NumberSequence.new(nukeAfterThrustSizeSeq)
  330. ExplosionRing.Size = NumberSequence.new(nukeAfterThrustSizeSeq)
  331. ExplosionSphere.Texture = "http://www.roblox.com/asset/?id=528256032"
  332. ExplosionRing.Texture = "http://www.roblox.com/asset/?id=528256032"
  333. ExplosionSphere.Transparency = NumberSequence.new(nukeAfterThrustTransparencySeq)
  334. ExplosionRing.Transparency = NumberSequence.new(nukeThrusterTransparencySeq)
  335. ExplosionSphere.ZOffset = 0
  336. ExplosionRing.ZOffset = -1
  337. ExplosionSphere.Name = "ExplosionA"
  338. ExplosionRing.Name = "ExplosionB"
  339. ExplosionSphere.EmissionDirection="Top"
  340. ExplosionRing.EmissionDirection= "Front"
  341. ExplosionSphere.Acceleration = Vector3.new(0,-30,0)
  342. ExplosionRing.Acceleration = Vector3.new(0,-5,0)
  343. ExplosionSphere.Enabled = false
  344. ExplosionRing.Enabled = false
  345. ExplosionSphere.Lifetime = NumberRange.new(1,3)
  346. ExplosionRing.Lifetime = NumberRange.new(1,3)
  347. ExplosionSphere.Rate = 200
  348. ExplosionRing.Rate = 200
  349. ExplosionSphere.Drag = 10
  350. ExplosionRing.Drag = 10
  351. ExplosionSphere.Speed = NumberRange.new(180,220)
  352. ExplosionRing.Speed = NumberRange.new(300,300)
  353. ExplosionSphere.SpreadAngle = Vector2.new(180,180)
  354. ExplosionRing.SpreadAngle = Vector2.new(1,180)
  355. radialBreakJoints(collisionPosition, 20)
  356. ExplosionSphere:Emit(300)
  357. ExplosionRing:Emit(300)
  358. wait(1.1)
  359. nuke:Destroy()
  360. for index,dict in pairs(projectiles) do
  361. if currentNukeIndex == dict["ID"] then
  362. table.remove(projectiles,index)
  363. end
  364. end
  365. end)
  366. end
  367. local targPos = Vector3.new(0,50,0)
  368. if dict["followsMouse"] == true then
  369. targPos = mousePos
  370. elseif dict["followMouse"] == false then
  371. targPos = dict["targetPart"].Position
  372. end
  373. local nukeVelocityDir = nuke.CFrame.LookVector
  374. local nukeTargetDir = CFrame.new(nuke.Position, targPos).LookVector
  375. local nukeDegreesToTarget = math.deg( math.acos(nukeVelocityDir.unit:Dot(nukeTargetDir.unit)) )
  376. local nukeAxisToTarget = nukeVelocityDir:Cross(nukeTargetDir)
  377. local nukeTurnAmount = math.clamp(nukeDegreesToTarget, -nukeTurnRate, nukeTurnRate)
  378. --============================== • Linear Rotation Part • ========================================--
  379. if nukeDegreesToTarget > 0 and nukeAtTargetHeight == true then
  380. local rotCF = (CFrame.fromAxisAngle(nukeAxisToTarget ,math.rad(nukeTurnAmount)) * nuke.CFrame)
  381. local x, y, z = rotCF:ToEulerAnglesYXZ()
  382. --print((tostring(x) .. " " .. tostring(y) .. " " .. tostring(z)))
  383. nuke.CFrame = CFrame.new(nuke.Position) * CFrame.fromEulerAnglesYXZ(x,y,z)
  384. end
  385. --============ • Move Part • =========--
  386. nuke.Position = nuke.Position + nuke.CFrame.LookVector * 2
  387. elseif dict["collision"] == true then
  388.  
  389. end
  390. --end)
  391. end
  392. end
  393. --Planned: Missile, Sentry, Bowling ball, weird other stuff
  394. spawn(function()
  395. game:GetService("RunService").Heartbeat:Connect(function(step)
  396. animationTimer = animationTimer - step
  397. animateCannon()
  398. projectileUpdate()
  399. end)
  400. end)
  401. wait(2)
  402. cannonFireNuke()
  403. wait(2.5)
  404. cannonFireNuke()
  405. wait(2.5)
  406. cannonFireNuke()
  407. while wait(2) do
  408. spawn(function()
  409.  
  410. end)
  411. end
  412.  
  413. local sound = Instance.new("Sound",workspace.VarixDog.Torso)
  414. sound.SoundId = "rbxassetid://5232019423"
  415. sound.Volume = 0.5
  416. sound.MaxDistance = 300
  417. sound.Looped = true
  418. sound:Play()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement