robloxboblox

Infinite Ammo Rifle

May 6th, 2021 (edited)
1,345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.97 KB | None | 0 0
  1. -- Decompiled with the Synapse X Luau decompiler.
  2. game.Players.LocalPlayer.Backpack.Rifle.LocalScript:Destroy()
  3. script.Parent = game.Players.LocalPlayer.Backpack.Rifle
  4. local l__RenderStepped__1 = game:GetService("RunService").RenderStepped;
  5. local l__LocalPlayer__2 = game.Players.LocalPlayer;
  6. local l__mouse__3 = l__LocalPlayer__2:GetMouse();
  7. local u1 = false;
  8. local u2 = nil;
  9. local l__WeaponDisplay__3 = script.Parent:WaitForChild("WeaponDisplay");
  10. local u4 = math.huge;
  11. local u5 = false;
  12. local u6 = nil;
  13. local u7 = nil;
  14. script.Parent.Equipped:connect(function()
  15. u1 = true;
  16. u2 = l__WeaponDisplay__3:Clone();
  17. u2.Parent = game.Players.LocalPlayer.PlayerGui;
  18. u2.Frame.Ammo.Text = u4 .. " / " .. 10;
  19. game:GetService("ContextActionService"):BindAction("Reload", reload, false, "r");
  20. game:GetService("UserInputService").InputBegan:connect(function(p1)
  21. if p1.KeyCode == Enum.KeyCode.ButtonX then
  22. reload();
  23. end;
  24. end);
  25. u2.Frame.ReloadReminder.MouseButton1Click:connect(reload);
  26. u2.Frame.ShootButton.MouseButton1Down:connect(fireWeapon);
  27. if game:GetService("UserInputService").GamepadEnabled then
  28. u2.Frame.ReloadReminder.xboxHint.Visible = true;
  29. u2.Frame.ShootButton.xboxHint.Visible = true;
  30. end;
  31. if game:GetService("UserInputService").TouchEnabled == true then
  32. u2.Frame.Size = UDim2.new(0.1, 0, 0.1, 0);
  33. u2.Frame.Position = UDim2.new(1, -10, 0.4, 0);
  34. u2.Frame.ShootButton.Visible = true;
  35. u2.MobileAim.Visible = true;
  36. u5 = true;
  37. end;
  38. u6 = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Idle);
  39. u7 = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Shoot);
  40. u6:Play();
  41. end);
  42. local u8 = false;
  43. local u9 = false;
  44. script.Parent.Unequipped:connect(function()
  45. u1 = false;
  46. u8 = false;
  47. u9 = false;
  48. local l__WeaponDisplay__4 = game.Players.LocalPlayer.PlayerGui:FindFirstChild("WeaponDisplay");
  49. if l__WeaponDisplay__4 then
  50. l__WeaponDisplay__4:Destroy();
  51. end;
  52. u6:Stop();
  53. u7:Stop();
  54. game:GetService("ContextActionService"):UnbindAction("Reload");
  55. end);
  56. game.Players.LocalPlayer.Character.Humanoid.Died:connect(function()
  57. local l__WeaponDisplay__5 = game.Players.LocalPlayer.PlayerGui:FindFirstChild("WeaponDisplay");
  58. if l__WeaponDisplay__5 then
  59. l__WeaponDisplay__5:Destroy();
  60. end;
  61. end);
  62. l__mouse__3.Button1Down:connect(function()
  63. if not u5 then
  64. while wait() do
  65. fireWeapon();
  66. end
  67. end;
  68. end);
  69. local l__Projectiles__10 = game.Workspace.Events.Projectiles;
  70. local u11 = 0;
  71. function fireWeapon()
  72. if u1 then
  73. if not u8 then
  74. if not u9 then
  75. if game:GetService("UserInputService").GamepadEnabled then
  76. u2.Frame.ReloadReminder.xboxHint.Visible = true;
  77. end;
  78. if u4 == 0 then
  79. u2.Frame.ReloadReminder.Visible = true;
  80. return;
  81. end;
  82. u8 = true;
  83. u4 = u4 - 1;
  84. if u4 == 0 then
  85. u2.Frame.ReloadReminder.Visible = true;
  86. end;
  87. u2.Frame.Ammo.Text = u4 .. " / " .. 10;
  88. local v6 = script.Parent.Handle.FireSound:Clone();
  89. v6.Parent = script.Parent.Handle;
  90. v6:Destroy();
  91. game.Workspace.Events.Projectiles.GunSound:FireServer(script.Parent.Handle);
  92. u7:Play();
  93. if l__LocalPlayer__2.Character then
  94. if 0 < l__LocalPlayer__2.Character.Humanoid.Health then
  95. local v7 = l__mouse__3.Hit;
  96. if u5 then
  97. local l__AbsolutePosition__8 = u2.MobileAim.AbsolutePosition;
  98. local l__AbsoluteSize__9 = u2.MobileAim.AbsoluteSize;
  99. local l__Magnitude__10 = (l__LocalPlayer__2.Character.Head.Position - game.Workspace.CurrentCamera.CFrame.p).Magnitude;
  100. local v11 = game.Workspace.CurrentCamera:ScreenPointToRay(l__AbsolutePosition__8.X + l__AbsoluteSize__9.X / 2, l__AbsolutePosition__8.Y + l__AbsoluteSize__9.Y / 2, 0);
  101. local v12, v13 = game.Workspace:FindPartOnRay(Ray.new(v11.Origin, v11.Direction * 10000), l__LocalPlayer__2.Character);
  102. v7 = CFrame.new(v13);
  103. end;
  104. local l__Position__14 = script.Parent.Handle.Position;
  105. local l__lookVector__15 = CFrame.new(l__Position__14, v7.p).lookVector;
  106. l__Projectiles__10.ProjectileRenderEvent:FireServer(0, l__LocalPlayer__2.Name, 1, l__Position__14, v7, 20, 1000);
  107. coroutine.wrap(function()
  108. local v16 = game.ReplicatedStorage.Projectile:Clone();
  109. v16.Parent = game.Workspace;
  110. local v17 = 0;
  111. local v18 = l__Position__14;
  112. local v19 = 2;
  113. while true do
  114. if v17 < 1000 then
  115.  
  116. else
  117. break;
  118. end;
  119. local v20, v21 = game.Workspace:FindPartOnRay(Ray.new(v18, l__lookVector__15.unit * v19), game.Players.LocalPlayer.Character, true, true);
  120. v18 = v21;
  121. if not v20 then
  122.  
  123. else
  124. local l__Body__22 = v20.Parent:FindFirstChild("Body");
  125. if l__Body__22 then
  126. l__Projectiles__10.HealthChange:FireServer(l__Body__22.Parent.OwnerName.Value, 20, u11);
  127. end;
  128. local l__Body__23 = v20.Parent.Parent:FindFirstChild("Body");
  129. if l__Body__23 then
  130. l__Projectiles__10.HealthChange:FireServer(l__Body__23.Parent.OwnerName.Value, 20, u11);
  131. end;
  132. l__Projectiles__10.ProjectileRenderEvent:FireServer(1, l__LocalPlayer__2.Name, 1, l__Position__14, v7, 20, 1000, nil, v20, u11);
  133. break;
  134. end;
  135. v16.CFrame = CFrame.new(v18, v18 + l__lookVector__15);
  136. if v19 * 2 < 20 then
  137. v19 = v19 * 2;
  138. elseif v19 ~= 20 then
  139. v19 = 20;
  140. end;
  141. v17 = v17 + v19;
  142. l__RenderStepped__1:wait();
  143. end;
  144. v16:Destroy();
  145. end)();
  146. end;
  147. end;
  148. u8 = false;
  149. u7:Stop();
  150. end;
  151. end;
  152. end;
  153. end;
  154. local u12 = 0;
  155. function reload()
  156. if u9 then
  157. return;
  158. end;
  159. u12 = u12 + 1;
  160. u9 = true;
  161. u8 = false;
  162. script.Parent.Handle.ReloadSound:Play();
  163. if u12 ~= u12 then
  164. print("cancel reload");
  165. return;
  166. end;
  167. u4 = math.huge;
  168. u2.Frame.Ammo.Text = u4 .. " / " .. 10;
  169. u2.Frame.ReloadReminder.Visible = false;
  170. u9 = false;
  171. end;
  172. game.Workspace.Events.S.SEvent.OnClientEvent:connect(function(p2)
  173. u11 = p2;
  174. end);
  175.  
  176.  
Add Comment
Please, Sign In to add comment