Advertisement
Zach_rookie_editor3

rl

Feb 23rd, 2020
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.73 KB | None | 0 0
  1. if game:GetService("RunService"):IsClient() then error("Please run as a server script. Use h/ instead of hl/.") end
  2. print("FE Compatibility: by WaverlyCole & Mokiros")
  3. InternalData = {}
  4. do
  5. script.Parent = owner.Character
  6. local Event = Instance.new("RemoteEvent")
  7. Event.Name = "UserInput"
  8. local function NewFakeEvent()
  9. local Fake = {fakeEvent=true,Connect=function(self,Func)self.Function=Func end}Fake.connect = Fake.Connect
  10. return Fake
  11. end
  12. local Mouse = {Target=nil,Hit=CFrame.new(),KeyUp=NewFakeEvent(),KeyDown=NewFakeEvent(),Button1Up=NewFakeEvent(),Button1Down=NewFakeEvent()}
  13. local UserInputService = {InputBegan=NewFakeEvent(),InputEnded=NewFakeEvent()}
  14. local ContextActionService = {Actions={},BindAction = function(self,actionName,Func,touch,...)
  15. self.Actions[actionName] = Func and {Name=actionName,Function=Func,Keys={...}} or nil
  16. end};ContextActionService.UnBindAction = ContextActionService.BindAction
  17. local function TriggerEvent(self,Event,...)
  18. local Trigger = Mouse[Event]
  19. if Trigger and Trigger.fakeEvent and Trigger.Function then
  20. Trigger.Function(...)
  21. end
  22. end
  23. Mouse.TrigEvent = TriggerEvent
  24. UserInputService.TrigEvent = TriggerEvent
  25. Event.OnServerEvent:Connect(function(FiredBy,Input)
  26. if FiredBy.Name ~= owner.Name then end
  27. if Input.MouseEvent then
  28. Mouse.Target = Input.Target
  29. Mouse.Hit = Input.Hit
  30. else
  31. local Begin = Input.UserInputState == Enum.UserInputState.Begin
  32. if Input.UserInputType == Enum.UserInputType.MouseButton1 then
  33. return Mouse:TrigEvent(Begin and "Button1Down" or "Button1Up")
  34. end
  35. for _,Action in pairs(ContextActionService.Actions) do
  36. for _,Key in pairs(Action.Keys) do
  37. if Key==Input.KeyCode then
  38. Action.Function(Action.Name,Input.UserInputState,Input)
  39. end
  40. end
  41. end
  42. Mouse:TrigEvent(Begin and "KeyDown" or "KeyUp",Input.KeyCode.Name:lower())
  43. UserInputService:TrigEvent(Begin and "InputBegan" or "InputEnded",Input,false)
  44. end
  45. end)
  46. InternalData["Mouse"] = Mouse
  47. InternalData["ContextActionService"] = ContextActionService
  48. InternalData["UserInputService"] = UserInputService
  49. Event.Parent = NLS([[
  50. local Player = owner
  51. local Event = script:WaitForChild("UserInput")
  52. local UserInputService = game:GetService("UserInputService")
  53. local Mouse = Player:GetMouse()
  54. local Input = function(Input,gameProcessedEvent)
  55. if gameProcessedEvent then return end
  56. Event:FireServer({KeyCode=Input.KeyCode,UserInputType=Input.UserInputType,UserInputState=Input.UserInputState})
  57. end
  58. UserInputService.InputBegan:Connect(Input)
  59. UserInputService.InputEnded:Connect(Input)
  60. local Hit,Target
  61. while wait(1/30) do
  62. if Hit ~= Mouse.Hit or Target ~= Mouse.Target then
  63. Hit,Target = Mouse.Hit,Mouse.Target
  64. Event:FireServer({["MouseEvent"]=true,["Target"]=Target,["Hit"]=Hit})
  65. end
  66. end
  67. ]],owner.Character)
  68. end
  69. RealGame = game;game = setmetatable({},{
  70. __index = function (self,Index)
  71. local Sandbox = function (Thing)
  72. if Thing:IsA("Player") then
  73. local RealPlayer = Thing
  74. return setmetatable({},{
  75. __index = function (self,Index)
  76. local Type = type(RealPlayer[Index])
  77. if Type == "function" then
  78. if Index:lower() == "getmouse" or Index:lower() == "mouse" then
  79. return function (self)
  80. return InternalData["Mouse"]
  81. end
  82. end
  83. return function (self,...)
  84. return RealPlayer[Index](RealPlayer,...)
  85. end
  86. else
  87. return RealPlayer[Index]
  88. end
  89. end;
  90. __tostring = function(self)
  91. return RealPlayer.Name
  92. end
  93. })
  94. end
  95. end
  96. if RealGame[Index] then
  97. local Type = type(RealGame[Index])
  98. if Type == "function" then
  99. if Index:lower() == "getservice" or Index:lower() == "service" then
  100. return function (self,Service)
  101. if Service:lower() == "players" then
  102. return setmetatable({},{
  103. __index = function (self2,Index2)
  104. local RealService = RealGame:GetService(Service)
  105. local Type2 = type(Index2)
  106. if Type2 == "function" then
  107. return function (self,...)
  108. return RealService[Index2](RealService,...)
  109. end
  110. else
  111. if Index2:lower() == "localplayer" then
  112. return Sandbox(owner)
  113. end
  114. return RealService[Index2]
  115. end
  116. end;
  117. __tostring = function(self)
  118. return RealGame:GetService(Service).Name
  119. end
  120. })
  121. elseif Service:lower() == "contextactionservice" then
  122. return InternalData["ContextActionService"]
  123. elseif Service:lower() == "contextactionservice" then
  124. return InternalData["UserInputService"]
  125. elseif Service:lower() == "runservice" then
  126. return setmetatable({},{
  127. __index = function(self2,Index2)
  128. local RealService = RealGame:GetService(Service)
  129. local Type2 = type(Index2)
  130. if Type2 == "function" then
  131. return function (self,...)
  132. return RealService[Index2](RealService,...)
  133. end
  134. else
  135. if Index2:lower() == "bindtorenderstep" then
  136. return function (self,Name,Priority,Function)
  137. return RealGame:GetService("RunService").Stepped:Connect(Function)
  138. end
  139. end
  140. if Index2:lower() == "renderstepped" then
  141. return RealService["Stepped"]
  142. end
  143. return RealService[Index2]
  144. end
  145. end
  146. })
  147. else
  148. return RealGame:GetService(Service)
  149. end
  150. end
  151. end
  152. return function (self,...)
  153. return RealGame[Index](RealGame,...)
  154. end
  155. else
  156. if game:GetService(Index) then
  157. return game:GetService(Index)
  158. end
  159. return RealGame[Index]
  160. end
  161. else
  162. return nil
  163. end
  164. end
  165. });Game = game;owner = game:GetService("Players").LocalPlayer
  166.  
  167. function sandbox(var,func)
  168. local env = getfenv(func)
  169. local newenv = setmetatable({},{
  170. __index = function(self,k)
  171. if k=="script" then
  172. return var
  173. else
  174. return env[k]
  175. end
  176. end,
  177. })
  178. setfenv(func,newenv)
  179. return func
  180. end
  181. cors = {}
  182. mas = Instance.new("Model",game:GetService("Lighting"))
  183. Tool0 = Instance.new("Tool")
  184. Part1 = Instance.new("Part")
  185. SpecialMesh2 = Instance.new("SpecialMesh")
  186. Script3 = Instance.new("Script")
  187. Sound4 = Instance.new("Sound")
  188. Sound5 = Instance.new("Sound")
  189. Script6 = Instance.new("Script")
  190. LocalScript7 = Instance.new("LocalScript")
  191. Configuration8 = Instance.new("Configuration")
  192. NumberValue9 = Instance.new("NumberValue")
  193. IntValue10 = Instance.new("IntValue")
  194. NumberValue11 = Instance.new("NumberValue")
  195. IntValue12 = Instance.new("IntValue")
  196. IntValue13 = Instance.new("IntValue")
  197. IntValue14 = Instance.new("IntValue")
  198. ModuleScript15 = Instance.new("ModuleScript")
  199. Tool0.Name = "RocketLauncher"
  200. Tool0.Parent = mas
  201. Tool0.TextureId = "http://www.roblox.com/asset/?id=90021376"
  202. Tool0.CanBeDropped = false
  203. Tool0.Grip = CFrame.new(0.699999988, 0, -0.5, 0, 0, -1, -1, 0, 0, 0, 1, 0)
  204. Tool0.GripForward = Vector3.new(1, -0, -0)
  205. Tool0.GripPos = Vector3.new(0.699999988, 0, -0.5)
  206. Tool0.GripRight = Vector3.new(0, -1, 0)
  207. Tool0.GripUp = Vector3.new(0, 0, 1)
  208. Part1.Name = "Handle"
  209. Part1.Parent = Tool0
  210. Part1.CFrame = CFrame.new(7.14963484, 0.420024008, -0.560084999, 1, 0, 0, 0, 6.30170107e-05, 1.00000024, 0, -1.00000024, 6.30170107e-05)
  211. Part1.Orientation = Vector3.new(-90, 0, 0)
  212. Part1.Position = Vector3.new(7.14963484, 0.420024008, -0.560084999)
  213. Part1.Rotation = Vector3.new(-90, 0, 0)
  214. Part1.Size = Vector3.new(4.92000628, 0.740000546, 0.839999795)
  215. Part1.BottomSurface = Enum.SurfaceType.Smooth
  216. Part1.TopSurface = Enum.SurfaceType.Smooth
  217. Part1.FormFactor = Enum.FormFactor.Custom
  218. Part1.formFactor = Enum.FormFactor.Custom
  219. SpecialMesh2.Parent = Part1
  220. SpecialMesh2.MeshId = "rbxasset://fonts/rocketlauncher.mesh"
  221. SpecialMesh2.Scale = Vector3.new(0.75, 0.75, 0.75)
  222. SpecialMesh2.TextureId = "rbxasset://textures/rocketlaunchertex.png"
  223. SpecialMesh2.MeshType = Enum.MeshType.FileMesh
  224. Script3.Parent = Tool0
  225. table.insert(cors,sandbox(Script3,function()
  226. local tool = script.Parent
  227. local canFire = true
  228. local gunWeld
  229.  
  230. -----------------
  231. --| Constants |--
  232. -----------------
  233.  
  234. local GRAVITY_ACCELERATION = 196.2
  235.  
  236. local RELOAD_TIME = tool.Configurations.ReloadTime.Value -- Seconds until tool can be used again
  237. local ROCKET_SPEED = tool.Configurations.RocketSpeed.Value -- Speed of the projectile
  238.  
  239. local MISSILE_MESH_ID = 'http://www.roblox.com/asset/?id=2251534'
  240. local MISSILE_MESH_SCALE = Vector3.new(0.35, 0.35, 0.25)
  241. local ROCKET_PART_SIZE = Vector3.new(1.2, 1.2, 3.27)
  242.  
  243. local RocketScript = script:WaitForChild('Rocket')
  244. local SwooshSound = script:WaitForChild('Swoosh')
  245. local BoomSound = script:WaitForChild('Boom')
  246.  
  247. local attackCooldown = tool.Configurations.AttackCooldown.Value
  248. local damage = tool.Configurations.Damage.Value
  249. local reloadTime = tool.Configurations.ReloadTime.Value
  250.  
  251. local function createEvent(eventName)
  252. local event = game.ReplicatedStorage:FindFirstChild(eventName)
  253. if not event then
  254. event = Instance.new("RemoteEvent", game.ReplicatedStorage)
  255. event.Name = eventName
  256. end
  257. return event
  258. end
  259.  
  260. local updateEvent = createEvent("ROBLOX_RocketUpdateEvent")
  261. local equipEvent = createEvent("ROBLOX_RocketEquipEvent")
  262. local unequipEvent = createEvent("ROBLOX_RocketUnequipEvent")
  263. local fireEvent = createEvent("ROBLOX_RocketFireEvent")
  264.  
  265. updateEvent.OnServerEvent:connect(function(player, neckC0, rshoulderC0)
  266. local character = player.Character
  267. local humanoid = character.Humanoid
  268.  
  269. if humanoid.Health <= 0 then return end
  270.  
  271. if humanoid.RigType == Enum.HumanoidRigType.R6 then
  272. character.Torso.Neck.C0 = neckC0
  273. character.Torso:FindFirstChild("Right Shoulder").C0 = rshoulderC0
  274. gunWeld = character:FindFirstChild("Right Arm"):WaitForChild("RightGrip")
  275.  
  276. elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
  277. character.Head.Neck.C0 = neckC0
  278. character.RightUpperArm.RightShoulder.C0 = rshoulderC0
  279. gunWeld = character.RightHand:WaitForChild("RightGrip")
  280. end
  281. end)
  282.  
  283. equipEvent.OnServerEvent:connect(function(player)
  284. player.Character.Humanoid.AutoRotate = false
  285. end)
  286.  
  287. unequipEvent.OnServerEvent:connect(function(player)
  288. player.Character.Humanoid.AutoRotate = true
  289. end)
  290.  
  291. --NOTE: We create the rocket once and then clone it when the player fires
  292. local Rocket = Instance.new('Part') do
  293. -- Set up the rocket part
  294. Rocket.Name = 'Rocket'
  295. Rocket.FormFactor = Enum.FormFactor.Custom --NOTE: This must be done before changing Size
  296. Rocket.Size = ROCKET_PART_SIZE
  297. Rocket.CanCollide = false
  298.  
  299. -- Add the mesh
  300. local mesh = Instance.new('SpecialMesh', Rocket)
  301. mesh.MeshId = MISSILE_MESH_ID
  302. mesh.Scale = MISSILE_MESH_SCALE
  303.  
  304. -- Add fire
  305. local fire = Instance.new('Fire', Rocket)
  306. fire.Heat = 5
  307. fire.Size = 2
  308.  
  309. -- Add a force to counteract gravity
  310. local bodyForce = Instance.new('BodyForce', Rocket)
  311. bodyForce.Name = 'Antigravity'
  312. bodyForce.force = Vector3.new(0, Rocket:GetMass() * GRAVITY_ACCELERATION, 0)
  313.  
  314. -- Clone the sounds and set Boom to PlayOnRemove
  315. local swooshSoundClone = SwooshSound:Clone()
  316. swooshSoundClone.Parent = Rocket
  317. local boomSoundClone = BoomSound:Clone()
  318. boomSoundClone.PlayOnRemove = true
  319. boomSoundClone.Parent = Rocket
  320.  
  321. -- Finally, clone the rocket script and enable it
  322. -- local rocketScriptClone = RocketScript:Clone()
  323. -- rocketScriptClone.Parent = Rocket
  324. -- rocketScriptClone.Disabled = false
  325. end
  326.  
  327.  
  328. fireEvent.OnServerEvent:connect(function(player, target)
  329. if canFire and player.Character == tool.Parent then
  330. canFire = false
  331.  
  332. -- Create a clone of Rocket and set its color
  333. local rocketClone = Rocket:Clone()
  334. --game.Debris:AddItem(rocketClone, 30)
  335. rocketClone.BrickColor = player.TeamColor
  336. rocketClone.Touched:connect(function(hit)
  337. if hit and hit.Parent and hit.Parent ~= player.Character and hit.Parent ~= tool then
  338. local explosion = Instance.new("Explosion", game.Workspace)
  339. explosion.Position = rocketClone.Position
  340. rocketClone:Destroy()
  341. end
  342. end)
  343.  
  344. spawn(function()
  345. wait(30)
  346. if rocketClone then rocketClone:Destroy() end
  347. end)
  348.  
  349. -- Position the rocket clone and launch!
  350. local spawnPosition = (tool.Handle.CFrame * CFrame.new(2, 0, 0)).p
  351. rocketClone.CFrame = CFrame.new(spawnPosition, target) --NOTE: This must be done before assigning Parent
  352. rocketClone.Velocity = rocketClone.CFrame.lookVector * ROCKET_SPEED --NOTE: This should be done before assigning Parent
  353. rocketClone.Parent = game.Workspace
  354.  
  355. -- Attach creator tags to the rocket early on
  356. local creatorTag = Instance.new('ObjectValue', rocketClone)
  357. creatorTag.Value = player
  358. creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website stats
  359. local iconTag = Instance.new('StringValue', creatorTag)
  360. iconTag.Value = tool.TextureId
  361. iconTag.Name = 'icon'
  362.  
  363. delay(attackCooldown, function()
  364. canFire = true
  365. end)
  366. end
  367. end)
  368. end))
  369. Sound4.Name = "Boom"
  370. Sound4.Parent = Script3
  371. Sound4.SoundId = "rbxasset://sounds/collide.wav"
  372. Sound4.Volume = 1
  373. Sound5.Name = "Swoosh"
  374. Sound5.Parent = Script3
  375. Sound5.Looped = true
  376. Sound5.SoundId = "rbxasset://sounds/Rocket whoosh 01.wav"
  377. Sound5.Volume = 0.69999998807907
  378. Script6.Name = "Rocket"
  379. Script6.Parent = Script3
  380. table.insert(cors,sandbox(Script6,function()
  381. -----------------
  382. --| Constants |--
  383. -----------------
  384. local BLAST_RADIUS = script.Parent.Parent.Configurations.BlastRadius.Value -- Blast radius of the explosion
  385. local BLAST_DAMAGE = script.Parent.Parent.Configurations.Damage.Value -- Amount of damage done to players
  386. local BLAST_FORCE = script.Parent.Parent.Configurations.BlastForce.Value -- Amount of force applied to parts
  387.  
  388. local IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} -- Rocket will fly through things named these
  389. --NOTE: Keys must be lowercase, values must evaluate to true
  390.  
  391. -----------------
  392. --| Variables |--
  393. -----------------
  394.  
  395. local DebrisService = game:GetService('Debris')
  396. local PlayersService = game:GetService('Players')
  397.  
  398. local Rocket = script.Parent
  399.  
  400. local CreatorTag = Rocket:WaitForChild('creator', 60)
  401. local SwooshSound = Rocket:WaitForChild('Swoosh', 60)
  402.  
  403. -----------------
  404. --| Functions |--
  405. -----------------
  406.  
  407. -- Removes any old creator tags and applies a new one to the target
  408. local function ApplyTags(target)
  409. while target:FindFirstChild('creator') do
  410. target.creator:Destroy()
  411. end
  412.  
  413. local creatorTagClone = CreatorTag:Clone()
  414. DebrisService:AddItem(creatorTagClone, 1.5)
  415. creatorTagClone.Parent = target
  416. end
  417.  
  418. -- Returns the ancestor that contains a Humanoid, if it exists
  419. local function FindCharacterAncestor(subject)
  420. if subject and subject ~= game.Workspace then
  421. local humanoid = subject:FindFirstChild('Humanoid')
  422. if humanoid then
  423. return subject, humanoid
  424. else
  425. return FindCharacterAncestor(subject.Parent)
  426. end
  427. end
  428. return nil
  429. end
  430.  
  431. -- Customized explosive effect that doesn't affect teammates and only breaks joints on dead parts
  432. local function OnExplosionHit(hitPart, hitDistance, blastCenter)
  433. if hitPart and hitDistance then
  434. local character, humanoid = FindCharacterAncestor(hitPart.Parent)
  435.  
  436. if character then
  437. local myPlayer = CreatorTag.Value
  438. if myPlayer and not myPlayer.Neutral then -- Ignore friendlies caught in the blast
  439. local player = PlayersService:GetPlayerFromCharacter(character)
  440. if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
  441. return
  442. end
  443. end
  444. end
  445.  
  446. if humanoid and humanoid.Health > 0 then -- Humanoids are tagged and damaged
  447. if hitPart.Name == 'Torso' then
  448. ApplyTags(humanoid)
  449. humanoid:TakeDamage(BLAST_DAMAGE)
  450. end
  451. else -- Loose parts and dead parts are blasted
  452. if hitPart.Name ~= 'Handle' then
  453. hitPart:BreakJoints()
  454. local blastForce = Instance.new('BodyForce', hitPart) --NOTE: We will multiply by mass so bigger parts get blasted more
  455. blastForce.force = (hitPart.Position - blastCenter).unit * BLAST_FORCE * hitPart:GetMass()
  456. DebrisService:AddItem(blastForce, 0.1)
  457. end
  458. end
  459. end
  460. end
  461.  
  462. local function OnTouched(otherPart)
  463. if Rocket and otherPart then
  464. -- Fly through anything in the ignore list
  465. if IGNORE_LIST[string.lower(otherPart.Name)] then
  466. return
  467. end
  468.  
  469. local myPlayer = CreatorTag.Value
  470. if myPlayer then
  471. -- Fly through the creator
  472. if myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then
  473. return
  474. end
  475.  
  476. -- Fly through friendlies
  477. if not myPlayer.Neutral then
  478. local character = FindCharacterAncestor(otherPart.Parent)
  479. local player = PlayersService:GetPlayerFromCharacter(character)
  480. if player and player ~= myPlayer and player.TeamColor == Rocket.BrickColor then
  481. return
  482. end
  483. end
  484. end
  485.  
  486. -- Fly through terrain water
  487. if otherPart == game.Workspace.Terrain then
  488. --NOTE: If the rocket is large, then the simplifications made here will cause it to fly through terrain in some cases
  489. local frontOfRocket = Rocket.Position + (Rocket.CFrame.lookVector * (Rocket.Size.Z / 2))
  490. local cellLocation = game.Workspace.Terrain:WorldToCellPreferSolid(frontOfRocket)
  491. local cellMaterial = game.Workspace.Terrain:GetCell(cellLocation.X, cellLocation.Y, cellLocation.Z)
  492. if cellMaterial == Enum.CellMaterial.Water or cellMaterial == Enum.CellMaterial.Empty then
  493. return
  494. end
  495. end
  496.  
  497. -- Create the explosion
  498. local explosion = Instance.new('Explosion')
  499. explosion.BlastPressure = 0 -- Completely safe explosion
  500. explosion.BlastRadius = BLAST_RADIUS
  501. explosion.ExplosionType = Enum.ExplosionType.NoCraters
  502. explosion.Position = Rocket.Position
  503. explosion.Parent = game.Workspace
  504.  
  505. -- Connect custom logic for the explosion
  506. explosion.Hit:connect(function(hitPart, hitDistance) OnExplosionHit(hitPart, hitDistance, explosion.Position) end)
  507.  
  508. -- Move this script and the creator tag (so our custom logic can execute), then destroy the rocket
  509. script.Parent = explosion
  510. CreatorTag.Parent = script
  511. Rocket:Destroy()
  512. end
  513. end
  514.  
  515. --------------------
  516. --| Script Logic |--
  517. --------------------
  518.  
  519. SwooshSound:Play()
  520.  
  521. Rocket.Touched:connect(OnTouched)
  522.  
  523. end))
  524. LocalScript7.Parent = Tool0
  525. table.insert(cors,sandbox(LocalScript7,function()
  526. -- Variables for services
  527. local render = game:GetService("RunService").RenderStepped
  528. local contextActionService = game:GetService("ContextActionService")
  529. local userInputService = game:GetService("UserInputService")
  530.  
  531. local player = game.Players.LocalPlayer
  532. local mouse = player:GetMouse()
  533. local Tool = script.Parent
  534.  
  535. -- Variables for Module Scripts
  536. local screenSpace = require(Tool:WaitForChild("ScreenSpace"))
  537.  
  538. local connection
  539.  
  540. local neck, shoulder, oldNeckC0, oldShoulderC0
  541.  
  542. local mobileShouldTrack = true
  543.  
  544. -- Thourough check to see if a character is sitting
  545. local function amISitting(character)
  546. return character.Humanoid.SeatPart ~= nil
  547. end
  548.  
  549. -- Function to call on renderstepped. Orients the character so it is facing towards
  550. -- the player mouse's position in world space. If character is sitting then the torso
  551. -- should not track
  552. local function frame(mousePosition)
  553. -- Special mobile consideration. We don't want to track if the user was touching a ui
  554. -- element such as the movement controls. Just return out of function if so to make sure
  555. -- character doesn't track
  556. if not mobileShouldTrack then return end
  557.  
  558. --This math is completely wrong with R15. We're better off just not doing it at all
  559. if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
  560. return
  561. end
  562.  
  563. -- Make sure character isn't swiming. If the character is swimming the following code will
  564. -- not work well; the character will not swim correctly. Besides, who shoots underwater?
  565. if player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming then
  566. local torso = player.Character.HumanoidRootPart
  567. local head = player.Character.Head
  568.  
  569. local toMouse = (mousePosition - head.Position).unit
  570. local angle = math.acos(toMouse:Dot(Vector3.new(0,1,0)))
  571.  
  572. local neckAngle = angle
  573.  
  574. -- Limit how much the head can tilt down. Too far and the head looks unnatural
  575. if math.deg(neckAngle) > 110 then
  576. neckAngle = math.rad(110)
  577. end
  578. neck.C0 = CFrame.new(0,1,0) * CFrame.Angles(math.pi - neckAngle,math.pi,0)
  579.  
  580. -- Calculate horizontal rotation
  581. local arm do
  582. arm = player.Character:FindFirstChild("Right Arm") or
  583. player.Character:FindFirstChild("RightUpperArm")
  584. end
  585. local fromArmPos = torso.Position + torso.CFrame:vectorToWorldSpace(Vector3.new(
  586. torso.Size.X/2 + arm.Size.X/2, torso.Size.Y/2 - arm.Size.Z/2, 0))
  587. local toMouseArm = ((mousePosition - fromArmPos) * Vector3.new(1,0,1)).unit
  588. local look = (torso.CFrame.lookVector * Vector3.new(1,0,1)).unit
  589. local lateralAngle = math.acos(toMouseArm:Dot(look))
  590.  
  591. -- Check for rogue math
  592. if tostring(lateralAngle) == "-1.#IND" then
  593. lateralAngle = 0
  594. end
  595.  
  596. -- Handle case where character is sitting down
  597. if player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Seated then
  598.  
  599. local cross = torso.CFrame.lookVector:Cross(toMouseArm)
  600. if lateralAngle > math.pi/2 then
  601. lateralAngle = math.pi/2
  602. end
  603. if cross.Y < 0 then
  604. lateralAngle = -lateralAngle
  605. end
  606. end
  607.  
  608. -- Turn shoulder to point to mouse
  609. shoulder.C0 = CFrame.new(1,0.5,0) * CFrame.Angles(math.pi/2 - angle,math.pi/2 + lateralAngle,0)
  610.  
  611. -- If not sitting then aim torso laterally towards mouse
  612. if not amISitting(player.Character) then
  613. torso.CFrame = CFrame.new(torso.Position, torso.Position + (Vector3.new(
  614. mousePosition.X, torso.Position.Y, mousePosition.Z)-torso.Position).unit)
  615. end
  616. end
  617. end
  618.  
  619. -- Function to bind to render stepped if player is on PC
  620. local function pcFrame()
  621. frame(mouse.Hit.p)
  622. end
  623.  
  624. -- Function to bind to touch moved if player is on mobile
  625. local function mobileFrame(touch, processed)
  626. -- Check to see if the touch was on a UI element. If so, we don't want to update anything
  627. if not processed then
  628. -- Calculate touch position in world space. Uses Stravant's ScreenSpace Module script
  629. -- to create a ray from the camera.
  630. local test = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1)
  631. local nearPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1))
  632. nearPos = game.Workspace.CurrentCamera.CoordinateFrame.p - nearPos
  633. local farPos = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y,50)
  634. farPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(farPos) * -1
  635. if farPos.magnitude > 900 then
  636. farPos = farPos.unit * 900
  637. end
  638. local ray = Ray.new(nearPos, farPos)
  639. local part, pos = game.Workspace:FindPartOnRay(ray, player.Character)
  640.  
  641. -- if a position was found on the ray then update the character's rotation
  642. if pos then
  643. frame(pos)
  644. end
  645. end
  646. end
  647.  
  648. local function OnActivated()
  649. local myModel = player.Character
  650. if Tool.Enabled and myModel and myModel:FindFirstChild('Humanoid') and myModel.Humanoid.Health > 0 then
  651. Tool.Enabled = false
  652. game.ReplicatedStorage.ROBLOX_RocketFireEvent:FireServer(mouse.Hit.p)
  653. wait(2)
  654.  
  655. Tool.Enabled = true
  656. end
  657. end
  658.  
  659. local oldIcon = nil
  660. -- Function to bind to equip event
  661. local function equip()
  662. local character = player.Character
  663. local humanoid = character.Humanoid
  664.  
  665. -- Setup joint variables
  666. if humanoid.RigType == Enum.HumanoidRigType.R6 then
  667. local torso = character.Torso
  668. neck = torso.Neck
  669. shoulder = torso["Right Shoulder"]
  670.  
  671. elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
  672. neck = character.Head.Neck
  673. shoulder = character.RightUpperArm.RightShoulder
  674. end
  675.  
  676. oldNeckC0 = neck.C0
  677. oldShoulderC0 = shoulder.C0
  678.  
  679. -- Remember old mouse icon and update current
  680. oldIcon = mouse.Icon
  681. mouse.Icon = "http://www.roblox.com/asset/?id=79658449"
  682.  
  683. -- Bind TouchMoved event if on mobile. Otherwise connect to renderstepped
  684. if userInputService.TouchEnabled then
  685. connection = userInputService.TouchMoved:connect(mobileFrame)
  686. else
  687. connection = render:connect(pcFrame)
  688. end
  689.  
  690. -- Bind TouchStarted and TouchEnded. Used to determine if character should rotate
  691. -- during touch input
  692. userInputService.TouchStarted:connect(function(touch, processed)
  693. mobileShouldTrack = not processed
  694. end)
  695. userInputService.TouchEnded:connect(function(touch, processed)
  696. mobileShouldTrack = false
  697. end)
  698.  
  699. -- If game uses filtering enabled then need to update server while tool is
  700. -- held by character.
  701. if workspace.FilteringEnabled then
  702. while connection and connection.Connected do
  703. wait()
  704. game.ReplicatedStorage.ROBLOX_RocketUpdateEvent:FireServer(neck.C0, shoulder.C0)
  705. end
  706. end
  707. end
  708.  
  709. -- Function to bind to Unequip event
  710. local function unequip()
  711. if connection then connection:disconnect() end
  712.  
  713. mouse.Icon = oldIcon
  714.  
  715. neck.C0 = oldNeckC0
  716. shoulder.C0 = oldShoulderC0
  717. end
  718.  
  719. -- Bind tool events
  720. Tool.Equipped:connect(equip)
  721. Tool.Unequipped:connect(unequip)
  722. Tool.Activated:connect(OnActivated)
  723. end))
  724. Configuration8.Name = "Configurations"
  725. Configuration8.Parent = Tool0
  726. NumberValue9.Name = "AttackCooldown"
  727. NumberValue9.Parent = Configuration8
  728. NumberValue9.Value = 3
  729. IntValue10.Name = "Damage"
  730. IntValue10.Parent = Configuration8
  731. IntValue10.Value = 60
  732. NumberValue11.Name = "ReloadTime"
  733. NumberValue11.Parent = Configuration8
  734. NumberValue11.Value = 1
  735. IntValue12.Name = "BlastForce"
  736. IntValue12.Parent = Configuration8
  737. IntValue12.Value = 1000
  738. IntValue13.Name = "BlastRadius"
  739. IntValue13.Parent = Configuration8
  740. IntValue13.Value = 8
  741. IntValue14.Name = "RocketSpeed"
  742. IntValue14.Parent = Configuration8
  743. IntValue14.Value = 60
  744. ModuleScript15.Name = "ScreenSpace"
  745. ModuleScript15.Parent = Tool0
  746. table.insert(cors,sandbox(ModuleScript15,function()
  747. local PlayerMouse = Game:GetService('Players').LocalPlayer:GetMouse()
  748.  
  749. local ScreenSpace = {}
  750.  
  751. -- Getter functions, with a couple of hacks for Ipad pre-focus.
  752. function ScreenSpace.ViewSizeX()
  753. local x = PlayerMouse.ViewSizeX
  754. local y = PlayerMouse.ViewSizeY
  755. if x == 0 then
  756. return 1024
  757. else
  758. if x > y then
  759. return x
  760. else
  761. return y
  762. end
  763. end
  764. end
  765.  
  766. function ScreenSpace.ViewSizeY()
  767. local x = PlayerMouse.ViewSizeX
  768. local y = PlayerMouse.ViewSizeY
  769. if y == 0 then
  770. return 768
  771. else
  772. if x > y then
  773. return y
  774. else
  775. return x
  776. end
  777. end
  778. end
  779.  
  780. -- Nice getter for aspect ratio. Due to the checks in the ViewSize functions this
  781. -- will never fail with a divide by zero error.
  782. function ScreenSpace.AspectRatio()
  783. return ScreenSpace.ViewSizeX() / ScreenSpace.ViewSizeY()
  784. end
  785.  
  786. -- WorldSpace -> ScreenSpace. Raw function taking a world position and giving you the
  787. -- screen position.
  788. function ScreenSpace.WorldToScreen(at)
  789. local point = Workspace.CurrentCamera.CoordinateFrame:pointToObjectSpace(at)
  790. local aspectRatio = ScreenSpace.AspectRatio()
  791. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  792. local wfactor = aspectRatio*hfactor
  793. --
  794. local x = (point.x/point.z) / -wfactor
  795. local y = (point.y/point.z) / hfactor
  796. --
  797. return Vector2.new(ScreenSpace.ViewSizeX()*(0.5 + 0.5*x), ScreenSpace.ViewSizeY()*(0.5 + 0.5*y))
  798. end
  799.  
  800. -- ScreenSpace -> WorldSpace. Raw function taking a screen position and a depth and
  801. -- converting it into a world position.
  802. function ScreenSpace.ScreenToWorld(x, y, depth)
  803. local aspectRatio = ScreenSpace.AspectRatio()
  804. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  805. local wfactor = aspectRatio*hfactor
  806. --
  807. local xf, yf = x/ScreenSpace.ViewSizeX()*2 - 1, y/ScreenSpace.ViewSizeY()*2 - 1
  808. local xpos = xf * -wfactor * depth
  809. local ypos = yf * hfactor * depth
  810. --
  811. return Vector3.new(xpos, ypos, depth)
  812. end
  813.  
  814. -- ScreenSize -> WorldSize
  815. function ScreenSpace.ScreenWidthToWorldWidth(screenWidth, depth)
  816. local aspectRatio = ScreenSpace.AspectRatio()
  817. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  818. local wfactor = aspectRatio*hfactor
  819. local sx = ScreenSpace.ViewSizeX()
  820. --
  821. return -(screenWidth / sx) * 2 * wfactor * depth
  822. end
  823. function ScreenSpace.ScreenHeightToWorldHeight(screenHeight, depth)
  824. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  825. local sy = ScreenSpace.ViewSizeY()
  826. --
  827. return -(screenHeight / sy) * 2 * hfactor * depth
  828. end
  829.  
  830. -- WorldSize -> ScreenSize
  831. function ScreenSpace.WorldWidthToScreenWidth(worldWidth, depth)
  832. local aspectRatio = ScreenSpace.AspectRatio()
  833. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  834. local wfactor = aspectRatio*hfactor
  835. local sx = ScreenSpace.ViewSizeX()
  836. --
  837. return -(worldWidth * sx) / (2 * wfactor * depth)
  838. end
  839. function ScreenSpace.WorldHeightToScreenHeight(worldHeight, depth)
  840. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  841. local sy = ScreenSpace.ViewSizeY()
  842. --
  843. return -(worldHeight * sy) / (2 * hfactor * depth)
  844. end
  845.  
  846. -- WorldSize + ScreenSize -> Depth needed
  847. function ScreenSpace.GetDepthForWidth(screenWidth, worldWidth)
  848. local aspectRatio = ScreenSpace.AspectRatio()
  849. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  850. local wfactor = aspectRatio*hfactor
  851. local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
  852. --
  853. return -(sx * worldWidth) / (screenWidth * 2 * wfactor)
  854. end
  855. function ScreenSpace.GetDepthForHeight(screenHeight, worldHeight)
  856. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  857. local sy = ScreenSpace.ViewSizeY()
  858. --
  859. return -(sy * worldHeight) / (screenHeight * 2 * hfactor)
  860. end
  861.  
  862. -- ScreenSpace -> WorldSpace. Taking a screen height, and a depth to put an object
  863. -- at, and returning a size of how big that object has to be to appear that size
  864. -- at that depth.
  865. function ScreenSpace.ScreenToWorldByHeightDepth(x, y, screenHeight, depth)
  866. local aspectRatio = ScreenSpace.AspectRatio()
  867. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  868. local wfactor = aspectRatio*hfactor
  869. local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
  870. --
  871. local worldHeight = -(screenHeight/sy) * 2 * hfactor * depth
  872. --
  873. local xf, yf = x/sx*2 - 1, y/sy*2 - 1
  874. local xpos = xf * -wfactor * depth
  875. local ypos = yf * hfactor * depth
  876. --
  877. return Vector3.new(xpos, ypos, depth), worldHeight
  878. end
  879.  
  880. -- ScreenSpace -> WorldSpace. Taking a screen width, and a depth to put an object
  881. -- at, and returning a size of how big that object has to be to appear that size
  882. -- at that depth.
  883. function ScreenSpace.ScreenToWorldByWidthDepth(x, y, screenWidth, depth)
  884. local aspectRatio = ScreenSpace.AspectRatio()
  885. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  886. local wfactor = aspectRatio*hfactor
  887. local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
  888. --
  889. local worldWidth = (screenWidth/sx) * 2 * -wfactor * depth
  890. --
  891. local xf, yf = x/sx*2 - 1, y/sy*2 - 1
  892. local xpos = xf * -wfactor * depth
  893. local ypos = yf * hfactor * depth
  894. --
  895. return Vector3.new(xpos, ypos, depth), worldWidth
  896. end
  897.  
  898. -- ScreenSpace -> WorldSpace. Taking a screen height that you want that object to be
  899. -- and a world height that is the size of that object, and returning the position to
  900. -- put that object at to satisfy those.
  901. function ScreenSpace.ScreenToWorldByHeight(x, y, screenHeight, worldHeight)
  902. local aspectRatio = ScreenSpace.AspectRatio()
  903. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  904. local wfactor = aspectRatio*hfactor
  905. local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
  906. --
  907. local depth = - (sy * worldHeight) / (screenHeight * 2 * hfactor)
  908. --
  909. local xf, yf = x/sx*2 - 1, y/sy*2 - 1
  910. local xpos = xf * -wfactor * depth
  911. local ypos = yf * hfactor * depth
  912. --
  913. return Vector3.new(xpos, ypos, depth)
  914. end
  915.  
  916. -- ScreenSpace -> WorldSpace. Taking a screen width that you want that object to be
  917. -- and a world width that is the size of that object, and returning the position to
  918. -- put that object at to satisfy those.
  919. function ScreenSpace.ScreenToWorldByWidth(x, y, screenWidth, worldWidth)
  920. local aspectRatio = ScreenSpace.AspectRatio()
  921. local hfactor = math.tan(math.rad(Workspace.CurrentCamera.FieldOfView)/2)
  922. local wfactor = aspectRatio*hfactor
  923. local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
  924. --
  925. local depth = - (sx * worldWidth) / (screenWidth * 2 * wfactor)
  926. --
  927. local xf, yf = x/sx*2 - 1, y/sy*2 - 1
  928. local xpos = xf * -wfactor * depth
  929. local ypos = yf * hfactor * depth
  930. --
  931. return Vector3.new(xpos, ypos, depth)
  932. end
  933.  
  934. return ScreenSpace
  935.  
  936.  
  937.  
  938.  
  939. end))
  940. for i,v in pairs(mas:GetChildren()) do
  941. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  942. pcall(function() v:MakeJoints() end)
  943. end
  944. mas:Destroy()
  945. for i,v in pairs(cors) do
  946. spawn(function()
  947. pcall(v)
  948. end)
  949. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement