Advertisement
mr2meows

rpg

Jul 6th, 2022 (edited)
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.24 KB | None | 0 0
  1. -- Objects To Lua Make By HairBaconGamming --
  2. local Module_Scripts = {}
  3. local RocketLauncher = Instance.new("Tool")
  4. local Handle = Instance.new("Part")
  5. local Mesh = Instance.new("SpecialMesh")
  6. local Server = Instance.new("Script")
  7. local Swoosh = Instance.new("Sound")
  8. local Rocket = Instance.new("Script")
  9. local Boom = Instance.new("Sound")
  10.  
  11. -- Properties --
  12.  
  13. RocketLauncher.CanBeDropped = true
  14. RocketLauncher.Grip = CFrame.new(0.699999988, 0, -0.5, 0, 0, -1, -1, 0, 0, 0, 1, 0)
  15. RocketLauncher.GripForward = Vector3.new(1, -0, -0)
  16. RocketLauncher.GripPos = Vector3.new(0.699999988079071, 0, -0.5)
  17. RocketLauncher.GripRight = Vector3.new(0, -1, 0)
  18. RocketLauncher.GripUp = Vector3.new(0, 0, 1)
  19. RocketLauncher.Name = [[RocketLauncher]]
  20. RocketLauncher.Parent = owner.Backpack
  21. RocketLauncher.TextureId = [[http://www.roblox.com/asset/?id=90021376]]
  22.  
  23. Handle.BottomSurface = Enum.SurfaceType.Smooth
  24. Handle.CFrame = CFrame.new(-76.7302856, 0.420043945, -61.7727242, 1, 0, 0, 0, 6.30170107e-05, 1.00000024, 0, -1.00000024, 6.30170107e-05)
  25. Handle.CanCollide = false
  26. Handle.Name = [[Handle]]
  27. Handle.Orientation = Vector3.new(-90, 0, 0)
  28. Handle.Parent = RocketLauncher
  29. Handle.Position = Vector3.new(-76.73028564453125, 0.4200439453125, -61.77272415161133)
  30. Handle.Rotation = Vector3.new(-90, 0, 0)
  31. Handle.Size = Vector3.new(4.920006275177002, 0.7400005459785461, 0.839999794960022)
  32. Handle.TopSurface = Enum.SurfaceType.Smooth
  33.  
  34. Mesh.MeshId = [[rbxasset://fonts/rocketlauncher.mesh]]
  35. Mesh.MeshType = Enum.MeshType.FileMesh
  36. Mesh.Parent = Handle
  37. Mesh.Scale = Vector3.new(0.75, 0.75, 0.75)
  38. Mesh.TextureId = [[rbxasset://textures/rocketlaunchertex.png]]
  39.  
  40. function Server_ScriptfakeXD()
  41.  
  42. local script = Instance.new("Script",RocketLauncher)
  43. Server = script
  44. script.Name = [[Server]]
  45. local require_fake = require
  46. local require = function(Object)
  47. local functiom = Module_Scripts[Object]
  48. if functiom then
  49. return functiom()
  50. end
  51. return require_fake(Object)
  52. end
  53.  
  54. -----------------
  55. --| Constants |--
  56. -----------------
  57.  
  58. local GRAVITY_ACCELERATION = workspace.Gravity
  59.  
  60. local RELOAD_TIME = 0-- Seconds until tool can be used again
  61. local ROCKET_SPEED = 60 -- Speed of the projectile
  62.  
  63. local MISSILE_MESH_ID = nil
  64. local MISSILE_MESH_SCALE = Vector3.new(0.35, 0.35, 0.25)
  65. local ROCKET_PART_SIZE = Vector3.new(1.2, 1.2, 3.27)
  66.  
  67. -----------------
  68. --| Variables |--
  69. -----------------
  70.  
  71. local DebrisService = game:GetService('Debris')
  72. local PlayersService = game:GetService('Players')
  73.  
  74. local MyPlayer
  75. local Tool = RocketLauncher
  76. local ToolHandle = Tool:WaitForChild("Handle")
  77.  
  78. local MouseLoc = print("kys")
  79.  
  80. local RocketScript = script:WaitForChild('Rocket')
  81. local SwooshSound = script:WaitForChild('Swoosh')
  82. local BoomSound = script:WaitForChild('Boom')
  83.  
  84. --NOTE: We create the rocket once and then clone it when the player fires
  85. local Rocket = Instance.new('Part') do
  86. -- Set up the rocket part
  87. Rocket.Name = 'Rocket'
  88. Rocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
  89. Rocket.Size = ROCKET_PART_SIZE
  90. Rocket.CanCollide = true
  91. Rocket.BackSurface = 3
  92. Rocket.BottomSurface = 3
  93. Rocket.FrontSurface = 3
  94. Rocket.LeftSurface = 3
  95. Rocket.RightSurface = 3
  96. Rocket.TopSurface = 3
  97. Rocket.Color = Color3.new(0.0509804, 0.411765, 0.67451)
  98. Rocket.Size = Vector3.new(1,1,4)
  99.  
  100. -- Add the mesh
  101. --local mesh = Instance.new('SpecialMesh', Rocket)
  102. --mesh.MeshId = MISSILE_MESH_ID
  103. --mesh.Scale = MISSILE_MESH_SCALE
  104.  
  105. -- Add fire
  106. local fire = Instance.new('Fire', Rocket)
  107. fire.Heat = 5
  108. fire.Size = 2
  109.  
  110. -- Add a force to counteract gravity
  111. local bodyForce = Instance.new('BodyForce', Rocket)
  112. bodyForce.Name = 'Antigravity'
  113. bodyForce.Force = Vector3.new(0, Rocket:GetMass() * GRAVITY_ACCELERATION, 0)
  114.  
  115. -- Clone the sounds and set Boom to PlayOnRemove
  116.  
  117. -- Attach creator tags to the rocket early on
  118. local creatorTag = Instance.new('ObjectValue', Rocket)
  119. creatorTag.Value = MyPlayer
  120. creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
  121. local iconTag = Instance.new('StringValue', creatorTag)
  122. iconTag.Value = Tool.TextureId
  123. iconTag.Name = 'icon'
  124.  
  125. -- Finally, clone the rocket script and enable it
  126. local rocketScriptClone = RocketScript:Clone()
  127. rocketScriptClone.Parent = Rocket
  128. rocketScriptClone.Disabled = false
  129. end
  130.  
  131. -----------------
  132. --| Functions |--
  133. -----------------
  134.  
  135. local function OnActivated()
  136. local myModel = MyPlayer.Character
  137. if Tool.Enabled and myModel and myModel:FindFirstChildOfClass("Humanoid") and myModel.Humanoid.Health > 0 then
  138. Tool.Enabled = false
  139. local Pos = ToolHandle.CFrame*CFrame.new(0,0,6).LookVector
  140. local pos2 = ToolHandle.CFrame*CFrame.new(0,0,6).Position
  141. local posc = ToolHandle.CFrame*CFrame.new(0,0,6)
  142. -- Create a clone of Rocket and set its color
  143. local rocketClone = Rocket:Clone()
  144. DebrisService:AddItem(rocketClone, 30)
  145. rocketClone.BrickColor = BrickColor.new(23)
  146.  
  147. -- Position the rocket clone and launch!
  148. local spawnPosition = (posc * CFrame.new(5, 0, 0)).p
  149. rocketClone.CFrame = Tool.Parent.Head.CFrame*CFrame.new(0,0,-6) --NOTE: This must be done before assigning Parent
  150. rocketClone.Velocity = rocketClone.CFrame.LookVector * ROCKET_SPEED --NOTE: This should be done before assigning Parent
  151. rocketClone.Parent = workspace
  152. rocketClone:SetNetworkOwner(nil)
  153. Rocket.Touched:Connect(OnTouched)
  154.  
  155. wait(RELOAD_TIME)
  156.  
  157. Tool.Enabled = true
  158. end
  159. end
  160.  
  161. function OnEquipped()
  162. MyPlayer = PlayersService:GetPlayerFromCharacter(Tool.Parent)
  163. end
  164.  
  165. --------------------
  166. --| Script Logic |--
  167. --------------------
  168.  
  169. Tool.Equipped:Connect(OnEquipped)
  170. Tool.Activated:Connect(OnActivated)
  171.  
  172.  
  173. end
  174. coroutine.wrap(Server_ScriptfakeXD)()
  175.  
  176.  
  177. Swoosh.Looped = true
  178. Swoosh.Name = [[Swoosh]]
  179. Swoosh.Parent = Server
  180. Swoosh.SoundId = [[rbxasset://sounds/Rocket whoosh 01.wav]]
  181. Swoosh.Volume = 0.699999988079071
  182.  
  183. function Rocket_ScriptfakeXD()
  184.  
  185. local script = Instance.new("Script",Server)
  186. Rocket = script
  187. script.Name = [[Rocket]]
  188. local require_fake = require
  189. local require = function(Object)
  190. local functiom = Module_Scripts[Object]
  191. if functiom then
  192. return functiom()
  193. end
  194. return require_fake(Object)
  195. end
  196.  
  197. -----------------
  198. --| Constants |--
  199. -----------------
  200.  
  201. local BLAST_RADIUS = 8 -- Blast radius of the explosion
  202. local BLAST_DAMAGE = 60 -- Amount of damage done to players
  203. local BLAST_FORCE = 1000 -- Amount of force applied to parts
  204.  
  205. local IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} -- Rocket will fly through things named these
  206. --NOTE: Keys must be lowercase, values must evaluate to true
  207.  
  208. -----------------
  209. --| Variables |--
  210. -----------------
  211.  
  212. local DebrisService = game:GetService('Debris')
  213. local PlayersService = game:GetService('Players')
  214.  
  215. local Rocket = script.Parent
  216.  
  217. local CreatorTag = Rocket:WaitForChild('creator')
  218. local SwooshSound = Rocket:WaitForChild('Swoosh')
  219.  
  220. -----------------
  221. --| Functions |--
  222. -----------------
  223.  
  224. -- Removes any old creator tags and applies a new one to the target
  225. local function ApplyTags(target)
  226. while target:FindFirstChild('creator') do
  227. target.creator:Destroy()
  228. end
  229.  
  230. local creatorTagClone = CreatorTag:Clone()
  231. DebrisService:AddItem(creatorTagClone, 1.5)
  232. creatorTagClone.Parent = target
  233. end
  234.  
  235. -- Returns the ancestor that contains a Humanoid, if it exists
  236. local function FindCharacterAncestor(subject)
  237. if subject and subject ~= workspace then
  238. local humanoid = subject:FindFirstChildOfClass('Humanoid')
  239. if humanoid then
  240. return subject, humanoid
  241. else
  242. return FindCharacterAncestor(subject.Parent)
  243. end
  244. end
  245. return nil
  246. end
  247.  
  248. local function IsInTable(Table,Value)
  249. for _,v in pairs(Table) do
  250. if v == Value then
  251. return true
  252. end
  253. end
  254. return false
  255. end
  256.  
  257. -- Customized explosive effect that doesn't affect teammates and only breaks joints on dead parts
  258. local TaggedHumanoids = {}
  259. local function OnExplosionHit(hitPart, hitDistance, blastCenter)
  260. if hitPart and hitDistance then
  261. local character, humanoid = FindCharacterAncestor(hitPart.Parent)
  262.  
  263. if character then
  264. local myPlayer = CreatorTag.Value
  265. if myPlayer and not myPlayer.Neutral then -- Ignore friendlies caught in the blast
  266. local player = PlayersService:GetPlayerFromCharacter(character)
  267. if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
  268. return
  269. end
  270. end
  271. end
  272.  
  273. if humanoid and humanoid.Health > 0 then -- Humanoids are tagged and damaged
  274. if not IsInTable(TaggedHumanoids,humanoid) then
  275. print("Tagged")
  276. table.insert(TaggedHumanoids,humanoid)
  277. ApplyTags(humanoid)
  278. humanoid:TakeDamage(BLAST_DAMAGE)
  279. end
  280. else -- Loose parts and dead parts are blasted
  281. if hitPart.Name ~= 'Handle' then
  282. hitPart:BreakJoints()
  283. local blastForce = Instance.new('BodyForce', hitPart) --NOTE: We will multiply by mass so bigger parts get blasted more
  284. blastForce.Force = (hitPart.Position - blastCenter).unit * BLAST_FORCE * hitPart:GetMass()
  285. DebrisService:AddItem(blastForce, 0.1)
  286. end
  287. end
  288. end
  289. end
  290.  
  291. local function OnTouched(otherPart)
  292. if Rocket and otherPart then
  293. -- Fly through anything in the ignore list
  294. if IGNORE_LIST[string.lower(otherPart.Name)] then
  295. return
  296. end
  297.  
  298. local myPlayer = CreatorTag.Value
  299. if myPlayer then
  300. -- Fly through the creator
  301. if myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
  302. return
  303. end
  304.  
  305. -- Fly through friendlies
  306. if not myPlayer.Neutral then
  307. local character = FindCharacterAncestor(otherPart.Parent)
  308. local player = PlayersService:GetPlayerFromCharacter(character)
  309. if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
  310. return
  311. end
  312. end
  313. end
  314.  
  315. -- Fly through terrain water
  316. if otherPart == workspace.Terrain then
  317. --NOTE: If the rocket is large, then the simplifications made here will cause it to fly through terrain in some cases
  318. local frontOfRocket = Rocket.Position + (Rocket.CFrame.lookVector * (Rocket.Size.Z / 2))
  319. local cellLocation = workspace.Terrain:WorldToCellPreferSolid(frontOfRocket)
  320. local cellMaterial = workspace.Terrain:GetCell(cellLocation.X, cellLocation.Y, cellLocation.Z)
  321. if cellMaterial == Enum.CellMaterial.Water or cellMaterial == Enum.CellMaterial.Empty then
  322. return
  323. end
  324. end
  325.  
  326. -- Create the explosion
  327. local explosion = Instance.new('Explosion')
  328. explosion.BlastPressure = BLAST_RADIUS -- Completely safe explosion
  329. explosion.BlastRadius = BLAST_RADIUS
  330. explosion.ExplosionType = Enum.ExplosionType.CratersAndDebris
  331. explosion.Position = Rocket.Position
  332. explosion.Parent = workspace
  333.  
  334. -- Connect custom logic for the explosion
  335. explosion.Hit:Connect(function(hitPart, hitDistance) OnExplosionHit(hitPart, hitDistance, explosion.Position) end)
  336.  
  337. -- Move this script and the creator tag (so our custom logic can execute), then destroy the rocket
  338. script.Parent = explosion
  339. CreatorTag.Parent = script
  340. Rocket:Destroy()
  341. end
  342. end
  343.  
  344. --------------------
  345. --| Script Logic |--
  346. --------------------
  347.  
  348. SwooshSound:Play()
  349.  
  350. Rocket.Touched:Connect(OnTouched)
  351.  
  352.  
  353. end
  354. coroutine.wrap(Rocket_ScriptfakeXD)()
  355.  
  356.  
  357. Boom.Name = [[Boom]]
  358. Boom.Parent = Server
  359. Boom.SoundId = [[rbxasset://sounds/collide.wav]]
  360. Boom.Volume = 1
  361.  
  362. -- End --
  363. -- Thank for using --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement