Advertisement
Roblox_Xploits

atest

Mar 22nd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.10 KB | None | 0 0
  1. game:GetObjects("rbxassetid://147874307")[1].Parent = game.Players.LocalPlayer.PlayerGui
  2. --Errors: ModuleScript
  3. System = {}
  4.  
  5. System.Create = function(a, c)
  6. local e = Instance.new(a)
  7. for d, a in pairs(c) do
  8. local b, a = ypcall(function()
  9. return e[d]
  10. end)
  11. if b then
  12. e[d] = c[d]
  13. end
  14. end
  15. return e
  16. end
  17. function b(d, b)
  18. local c = getfenv(d)
  19. local a = setmetatable({}, {
  20. __index = function(a, a)
  21. if a:lower() == 'script' then
  22. return b
  23. else
  24. return c[a]
  25. end
  26. end
  27. })
  28. setfenv(d, a)
  29. ypcall(function()
  30. d()
  31. end)
  32. end
  33. c = {}
  34. mas = Instance.new("Model",game:GetService("Lighting"))
  35. mas.Name = "CompiledModel"
  36. o1 = System.Create("Tool",{
  37. ["Name"] = "Pistol",
  38. ["Parent"] = mas,
  39. ["GripForward"] = Vector3.new(-0, 1, -0),
  40. ["GripPos"] = Vector3.new(0, -0.400000006, -0.400000006),
  41. ["GripUp"] = Vector3.new(0, 0, 1),
  42. })
  43. o2 = System.Create("Configuration",{
  44. ["Name"] = "Configurations",
  45. ["Parent"] = o1,
  46. })
  47. o3 = System.Create("IntValue",{
  48. ["Name"] = "ClipSize",
  49. ["Parent"] = o2,
  50. ["Value"] = 8,
  51. })
  52. o4 = System.Create("NumberValue",{
  53. ["Name"] = "AttackCooldown",
  54. ["Parent"] = o2,
  55. ["Value"] = 0.15,
  56. })
  57. o5 = System.Create("NumberValue",{
  58. ["Name"] = "Range",
  59. ["Parent"] = o2,
  60. ["Value"] = 300,
  61. })
  62. o6 = System.Create("IntValue",{
  63. ["Name"] = "Damage",
  64. ["Parent"] = o2,
  65. ["Value"] = 20,
  66. })
  67. o7 = System.Create("NumberValue",{
  68. ["Name"] = "ReloadTime",
  69. ["Parent"] = o2,
  70. ["Value"] = 1,
  71. })
  72. o8 = System.Create("Part",{
  73. ["Name"] = "Handle",
  74. ["Parent"] = o1,
  75. ["BrickColor"] = BrickColor.new("Dark stone grey"),
  76. ["Position"] = Vector3.new(1.90734863e-006, 17.3299999, 21.9099998),
  77. ["Rotation"] = Vector3.new(-90.0001297, 0.000112511931, -7.13005102e-006),
  78. ["CFrame"] = CFrame.new(1.90734863e-006, 17.3299999, 21.9099998, 1, 1.24442863e-007, 1.96370365e-006, -1.96370365e-006, -2.29479701e-006, 1, 1.24447368e-007, -1, -2.29479679e-006),
  79. ["FormFactor"] = Enum.FormFactor.Custom,
  80. ["Size"] = Vector3.new(0.200000003, 0.800000012, 0.800000012),
  81. ["BackSurface"] = Enum.SurfaceType.Weld,
  82. ["BottomSurface"] = Enum.SurfaceType.Weld,
  83. ["FrontSurface"] = Enum.SurfaceType.Weld,
  84. ["LeftSurface"] = Enum.SurfaceType.Weld,
  85. ["RightSurface"] = Enum.SurfaceType.Weld,
  86. ["TopSurface"] = Enum.SurfaceType.Weld,
  87. ["Color"] = Color3.new(0.388235, 0.372549, 0.384314),
  88. })
  89. o9 = System.Create("SpecialMesh",{
  90. ["Parent"] = o8,
  91. ["MeshId"] = "http://www.roblox.com/asset/?id=72012879",
  92. ["Scale"] = Vector3.new(1.25, 1.25, 1.25),
  93. ["TextureId"] = "http://www.roblox.com/asset/?id=72012859",
  94. ["VertexColor"] = Vector3.new(2, 2, 2),
  95. ["MeshType"] = Enum.MeshType.FileMesh,
  96. })
  97. o10 = System.Create("LocalScript",{
  98. ["Parent"] = o1,
  99. })
  100. table.insert(c, coroutine.create(function()
  101. wait()
  102. b(function()
  103. -- Variables for services
  104. local render = game:GetService("RunService").RenderStepped
  105. local contextActionService = game:GetService("ContextActionService")
  106. local userInputService = game:GetService("UserInputService")
  107.  
  108. local player = game.Players.LocalPlayer
  109. local mouse = player:GetMouse()
  110. local Tool = script.Parent
  111.  
  112. -- Variables for Module Scripts
  113. local screenSpace = require(Tool:WaitForChild("ScreenSpace"))
  114.  
  115. local connection
  116. -- Variables for character joints
  117.  
  118. local neck, shoulder, oldNeckC0, oldShoulderC0
  119.  
  120. local mobileShouldTrack = true
  121.  
  122. -- Thourough check to see if a character is sitting
  123. local function amISitting(character)
  124. local t = character.Torso
  125. for _, part in pairs(t:GetConnectedParts(true)) do
  126. if part:IsA("Seat") or part:IsA("VehicleSeat") then
  127. return true
  128. end
  129. end
  130. end
  131.  
  132. -- Function to call on renderstepped. Orients the character so it is facing towards
  133. -- the player mouse's position in world space. If character is sitting then the torso
  134. -- should not track
  135. local function frame(mousePosition)
  136. -- Special mobile consideration. We don't want to track if the user was touching a ui
  137. -- element such as the movement controls. Just return out of function if so to make sure
  138. -- character doesn't track
  139. if not mobileShouldTrack then return end
  140.  
  141. -- Make sure character isn't swiming. If the character is swimming the following code will
  142. -- not work well; the character will not swim correctly. Besides, who shoots underwater?
  143. if player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming then
  144. local torso = player.Character.Torso
  145. local head = player.Character.Head
  146.  
  147. local toMouse = (mousePosition - head.Position).unit
  148. local angle = math.acos(toMouse:Dot(Vector3.new(0,1,0)))
  149.  
  150. local neckAngle = angle
  151.  
  152. -- Limit how much the head can tilt down. Too far and the head looks unnatural
  153. if math.deg(neckAngle) > 110 then
  154. neckAngle = math.rad(110)
  155. end
  156. neck.C0 = CFrame.new(0,1,0) * CFrame.Angles(math.pi - neckAngle,math.pi,0)
  157.  
  158. -- Calculate horizontal rotation
  159. local arm = player.Character:FindFirstChild("Right Arm")
  160. local fromArmPos = torso.Position + torso.CFrame:vectorToWorldSpace(Vector3.new(
  161. torso.Size.X/2 + arm.Size.X/2, torso.Size.Y/2 - arm.Size.Z/2, 0))
  162. local toMouseArm = ((mousePosition - fromArmPos) * Vector3.new(1,0,1)).unit
  163. local look = (torso.CFrame.lookVector * Vector3.new(1,0,1)).unit
  164. local lateralAngle = math.acos(toMouseArm:Dot(look))
  165.  
  166. -- Check for rogue math
  167. if tostring(lateralAngle) == "-1.#IND" then
  168. lateralAngle = 0
  169. end
  170.  
  171. -- Handle case where character is sitting down
  172. if player.Character.Humanoid:GetState() == Enum.HumanoidStateType.Seated then
  173.  
  174. local cross = torso.CFrame.lookVector:Cross(toMouseArm)
  175. if lateralAngle > math.pi/2 then
  176. lateralAngle = math.pi/2
  177. end
  178. if cross.Y < 0 then
  179. lateralAngle = -lateralAngle
  180. end
  181. end
  182.  
  183. -- Turn shoulder to point to mouse
  184. shoulder.C0 = CFrame.new(1,0.5,0) * CFrame.Angles(math.pi/2 - angle,math.pi/2 + lateralAngle,0)
  185.  
  186. -- If not sitting then aim torso laterally towards mouse
  187. if not amISitting(player.Character) then
  188. torso.CFrame = CFrame.new(torso.Position, torso.Position + (Vector3.new(
  189. mousePosition.X, torso.Position.Y, mousePosition.Z)-torso.Position).unit)
  190. else
  191. --print("sitting")
  192. end
  193. end
  194. end
  195.  
  196. -- Function to bind to render stepped if player is on PC
  197. local function pcFrame()
  198. frame(mouse.Hit.p)
  199. end
  200.  
  201. -- Function to bind to touch moved if player is on mobile
  202. local function mobileFrame(touch, processed)
  203. -- Check to see if the touch was on a UI element. If so, we don't want to update anything
  204. if not processed then
  205. -- Calculate touch position in world space. Uses Stravant's ScreenSpace Module script
  206. -- to create a ray from the camera.
  207. local test = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1)
  208. local nearPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y, 1))
  209. nearPos = game.Workspace.CurrentCamera.CoordinateFrame.p - nearPos
  210. local farPos = screenSpace.ScreenToWorld(touch.Position.X, touch.Position.Y,50)
  211. farPos = game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(farPos) * -1
  212. if farPos.magnitude > 900 then
  213. farPos = farPos.unit * 900
  214. end
  215. local ray = Ray.new(nearPos, farPos)
  216. local part, pos = game.Workspace:FindPartOnRay(ray, player.Character)
  217.  
  218. -- if a position was found on the ray then update the character's rotation
  219. if pos then
  220. frame(pos)
  221. end
  222. end
  223. end
  224.  
  225. local oldIcon = nil
  226. -- Function to bind to equip event
  227. local function equip()
  228. local torso = player.Character.Torso
  229.  
  230. -- Setup joint variables
  231. neck = torso.Neck
  232. oldNeckC0 = neck.C0
  233. shoulder = torso:FindFirstChild("Right Shoulder")
  234. oldShoulderC0 = shoulder.C0
  235.  
  236. -- Remember old mouse icon and update current
  237. oldIcon = mouse.Icon
  238. mouse.Icon = "http://www.roblox.com/asset/?id=79658449"
  239.  
  240. -- Bind TouchMoved event if on mobile. Otherwise connect to renderstepped
  241. if userInputService.TouchEnabled then
  242. connection = userInputService.TouchMoved:connect(mobileFrame)
  243. else
  244. connection = render:connect(pcFrame)
  245. end
  246.  
  247. -- Bind TouchStarted and TouchEnded. Used to determine if character should rotate
  248. -- during touch input
  249. userInputService.TouchStarted:connect(function(touch, processed)
  250. mobileShouldTrack = not processed
  251. end)
  252. userInputService.TouchEnded:connect(function(touch, processed)
  253. mobileShouldTrack = false
  254. end)
  255.  
  256. -- Fire server's equip event
  257. game.ReplicatedStorage.ROBLOX_PistolEquipEvent:FireServer()
  258.  
  259. -- Bind event for when mouse is clicked to fire server's fire event
  260. mouse.Button1Down:connect(function()
  261. game.ReplicatedStorage.ROBLOX_PistolFireEvent:FireServer(mouse.Hit.p)
  262. end)
  263.  
  264. -- Bind reload event to mobile button and r key
  265. contextActionService:BindActionToInputTypes("Reload", function()
  266. game.ReplicatedStorage.ROBLOX_PistolReloadEvent:FireServer()
  267. end, true, "r")
  268.  
  269. -- If game uses filtering enabled then need to update server while tool is
  270. -- held by character.
  271. if workspace.FilteringEnabled then
  272. while connection do
  273. wait()
  274. game.ReplicatedStorage.ROBLOX_PistolUpdateEvent:FireServer(neck.C0, shoulder.C0)
  275. end
  276. end
  277. end
  278.  
  279. -- Function to bind to Unequip event
  280. local function unequip()
  281. if connection then connection:disconnect() end
  282. contextActionService:UnbindAction("Reload")
  283. game.ReplicatedStorage.ROBLOX_PistolUnequipEvent:FireServer()
  284. mouse.Icon = oldIcon
  285. neck.C0 = oldNeckC0
  286. shoulder.C0 = oldShoulderC0
  287. end
  288.  
  289. -- Bind tool events
  290. Tool.Equipped:connect(equip)
  291. Tool.Unequipped:connect(unequip) end..o10)
  292. end))
  293.  
  294. o11 = System.Create("Script",{
  295. ["Parent"] = o1,
  296. })
  297. table.insert(c, coroutine.create(function()
  298. wait()
  299. b(function()
  300. -- Local variables
  301. local tool = script.Parent
  302. local currentAmmo = tool.Configurations.ClipSize.Value
  303. local canFire = true
  304. local reloading = false
  305. local fireSound = tool.FireSound
  306.  
  307. -- Configurable variables
  308. local attackCooldown = tool.Configurations.AttackCooldown.Value
  309. local range = tool.Configurations.Range.Value
  310. local damage = tool.Configurations.Damage.Value
  311. local reloadTime = tool.Configurations.ReloadTime.Value
  312. local clipSize = tool.Configurations.ClipSize.Value
  313.  
  314. -- Setup Remote Events
  315. local function createEvent(eventName)
  316. local event = game.ReplicatedStorage:FindFirstChild(eventName)
  317. if not event then
  318. event = Instance.new("RemoteEvent", game.ReplicatedStorage)
  319. event.Name = eventName
  320. end
  321. return event
  322. end
  323. local updateEvent = createEvent("ROBLOX_PistolUpdateEvent")
  324. local equipEvent = createEvent("ROBLOX_PistolEquipEvent")
  325. local unequipEvent = createEvent("ROBLOX_PistolUnequipEvent")
  326. local fireEvent = createEvent("ROBLOX_PistolFireEvent")
  327. local reloadEvent = createEvent("ROBLOX_PistolReloadEvent")
  328.  
  329. -- Add tracer decal to server storage if it isn't already there
  330. if not game.ServerStorage:FindFirstChild("ROBLOX_PistolTracerDecal") then
  331. tool.ROBLOX_PistolTracerDecal:Clone().Parent = game.ServerStorage
  332. end
  333.  
  334. -- Bind function to update event. Used to update player's orientation if FilteringEnabled
  335. -- is true (otherwise the rotation would not replicate from the rotating player)
  336. updateEvent.OnServerEvent:connect(function(player, neckC0, rshoulderC0)
  337. local character = player.Character
  338. character.Torso.Neck.C0 = neckC0
  339. character.Torso:FindFirstChild("Right Shoulder").C0 = rshoulderC0
  340. end)
  341.  
  342. -- Bind functions to when player equips/unequips the tool. Right now just need to turn on and
  343. -- off AutoRotate
  344. equipEvent.OnServerEvent:connect(function(player)
  345. player.Character.Humanoid.AutoRotate = false
  346. end)
  347. unequipEvent.OnServerEvent:connect(function(player)
  348. player.Character.Humanoid.AutoRotate = true
  349. end)
  350.  
  351. -- Creates "bullet". No projectile motion is actually used. Pistol raytraces to target and creates
  352. -- a tracer trail to the target. Fading trail gives illusion of motion.
  353. local function createBullet(target)
  354. -- Get actual handle position. Want to offset from the center of the handle as the bullet comes
  355. -- from the barrel of the gun
  356. local handlePos = tool.Handle.CFrame + tool.Handle.CFrame:vectorToWorldSpace(Vector3.new(0,0,.3))
  357. local toTarget = handlePos:vectorToWorldSpace(Vector3.new(0,1,0)) * 200
  358. local torsoLook = (tool.Parent:FindFirstChild("Torso").CFrame.lookVector * Vector3.new(1,0,1)).unit
  359. local toTargetAngle = (toTarget * Vector3.new(1,0,1)).unit
  360. local angle = math.acos(torsoLook:Dot(toTargetAngle))
  361.  
  362. -- Checks angle from where the character is facing to the orientation of the pistol. If the angle
  363. -- is less than 90 degress then we shoot to where the mouse is pointing (helps accuracy). Otherwise
  364. -- the gun is assumed at the edge of its rotation and just shoots straight.
  365. if math.deg(angle) < 90 then
  366. toTarget = target - tool.Handle.Position
  367. if toTarget.magnitude > range then
  368. toTarget = toTarget.unit * range
  369. end
  370. toTarget = toTarget * 1.1
  371. end
  372.  
  373. -- Shoot ray and check if humanoid was hit. If so, it should take damage
  374. local ray = Ray.new(handlePos.p, toTarget)
  375. local part, position = game.Workspace:FindPartOnRay(ray, tool.Parent)
  376. if part and part.Parent and part.Parent:FindFirstChild("Humanoid") then
  377. part.Parent:FindFirstChild("Humanoid"):TakeDamage(damage)
  378. end
  379.  
  380. if position then
  381. toTarget = position - handlePos.p
  382. end
  383.  
  384. -- Create tracer trail. Trail is made of thin parts 2 studs long. Fades each segment
  385. -- starting with closest tracer to the tool.
  386. local bulletTrail = Instance.new("Model", game.Workspace)
  387. local trailTable = {}
  388. -- Fetch decal from server storage
  389. local decal = game.ServerStorage.ROBLOX_PistolTracerDecal
  390. for i = 0, toTarget.magnitude/2, 1 do
  391. local trailSegment = Instance.new("Part", bulletTrail)
  392. trailSegment.CanCollide = false
  393. trailSegment.Anchored = true
  394. trailSegment.FormFactor = Enum.FormFactor.Custom
  395. trailSegment.Size = Vector3.new(.1,.1,2)
  396. trailSegment.BrickColor = BrickColor.White()
  397. trailSegment.CFrame = CFrame.new(handlePos.p + (toTarget.unit * 2 * (i + .5)), handlePos.p)
  398. trailSegment.Transparency = 1
  399.  
  400. -- Add point light to tracer for a little illumination
  401. local light = Instance.new("PointLight", trailSegment)
  402. light.Range = 3
  403.  
  404. -- Add decal to faces of the part
  405. local function addDecal(face)
  406. local decalClone = decal:Clone()
  407. decalClone.Parent = trailSegment
  408. decalClone.Face = face
  409. end
  410.  
  411. addDecal(Enum.NormalId.Top)
  412. addDecal(Enum.NormalId.Bottom)
  413. addDecal(Enum.NormalId.Left)
  414. addDecal(Enum.NormalId.Right)
  415.  
  416. -- Add segment to all of the tracers
  417. table.insert(trailTable, trailSegment)
  418. end
  419.  
  420. -- Coroutine thread to fade each trail segment. Put in coroutine so it does not
  421. -- block the rest of the pistol's script
  422. local fadeThread = coroutine.create(function()
  423. local count = 1
  424. local ended = false
  425. -- Keep looping until end condition is met
  426. while not ended do
  427. -- Assume end condition is met. Easier to switch it off later if we need to
  428. -- keep looping
  429. ended = true
  430. -- Loop through every part in the trail
  431. for index, part in pairs(trailTable) do
  432. if index <= count then
  433. local shouldDestroy = false
  434. for _, face in pairs(part:GetChildren()) do
  435.  
  436. if face:IsA("Decal") then
  437. -- Increase decal transparencies and use this to determine if
  438. -- segment has completely faded
  439. face.Transparency = face.Transparency + .05
  440. if face.Transparency < 1 then
  441. ended = false
  442. else
  443. shouldDestroy = true
  444. end
  445. else
  446. -- Dim the point light
  447. face.Brightness = face.Brightness - .1
  448. end
  449. end
  450. -- If segment is completely faded then clean it up
  451. if shouldDestroy then
  452. table.remove(trailTable, index)
  453. part:Destroy()
  454. end
  455. end
  456. end
  457. count = count + 1
  458. wait()
  459. end
  460. bulletTrail:Destroy()
  461. end)
  462. coroutine.resume(fadeThread)
  463. end
  464.  
  465. -- Function to bind to reload event
  466. local function reload()
  467. if not reloading then
  468. tool.ReloadSound:Play()
  469. reloading = true
  470. canFire = false
  471. wait(reloadTime)
  472. currentAmmo = clipSize
  473. canFire = true
  474. reloading = false
  475. end
  476. end
  477.  
  478. reloadEvent.OnServerEvent:connect(reload)
  479.  
  480. -- Bind function to fire event
  481. fireEvent.OnServerEvent:connect(function(player, target)
  482. if tool.Parent == player.Character then
  483. -- If tool has enough shots then fires. Otherwise reloads.
  484. if currentAmmo <= 0 then
  485. return reload()
  486. end
  487. if canFire then
  488. canFire = false
  489. currentAmmo = currentAmmo - 1
  490. fireSound:Play()
  491. createBullet(target)
  492. delay(attackCooldown, function()
  493. canFire = true
  494. end)
  495. end
  496. end
  497. end)
  498.  
  499. end..o11)
  500. end))
  501.  
  502. o12 = System.Create("Sound",{
  503. ["Name"] = "ReloadSound",
  504. ["Parent"] = o1,
  505. ["Pitch"] = 0.69999998807907,
  506. ["SoundId"] = "http://www.roblox.com/asset/?id=31762599",
  507. ["Volume"] = 1,
  508. })
  509. o13 = System.Create("Sound",{
  510. ["Name"] = "FireSound",
  511. ["Parent"] = o1,
  512. ["Pitch"] = 0.69999998807907,
  513. ["SoundId"] = "http://www.roblox.com/asset/?id=12221976",
  514. })
  515. o14 = System.Create("Decal",{
  516. ["Name"] = "ROBLOX_PistolTracerDecal",
  517. ["Parent"] = o1,
  518. ["Transparency"] = 0.5,
  519. ["Texture"] = "http://www.roblox.com/asset/?id=186982304",
  520. ["Face"] = Enum.NormalId.Top,
  521. })
  522. mas.Parent = workspace
  523. mas:MakeJoints()
  524. local b = mas:GetChildren()
  525. for a = 1, #b do
  526. b[a].Parent = workspace
  527. ypcall(function()
  528. b[a]:MakeJoints()
  529. end)
  530. end
  531. mas:Destroy()
  532. for a = 1, #c do
  533. coroutine.resume(c[a])
  534. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement