Advertisement
anphu04

Murder Mystery 2 - FULLY AUTOMATE 2

Sep 1st, 2023
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.25 KB | None | 0 0
  1. -- 28/2/2023: last exploit(s) before going home tomorrow
  2. COIN_TYPE = {'BeachBall'}
  3.  
  4. myplr = game.Players.LocalPlayer
  5. cam = workspace.CurrentCamera
  6. uis = game:GetService('UserInputService')
  7. pathfinder = game:GetService('PathfindingService')
  8. tweener = game:GetService('TweenService')
  9. vim = game:GetService('VirtualInputManager')
  10. run = game:GetService('RunService')
  11.  
  12. for i,v in pairs(workspace:GetDescendants()) do
  13.     if v.Name == 'CoinContainer' then
  14.         container = v
  15.         break
  16.     end
  17. end
  18. spawn(function()
  19.     while wait(2) do
  20.         if stop then break end
  21.  
  22.         -- prevent 20 minutes idle disconnection
  23.         if not hasgun then
  24.             vim:SendMouseButtonEvent(0,0,0, true, game,1)
  25.             vim:SendMouseButtonEvent(0,0,0, false, game,1)
  26.         end
  27.  
  28.         for i,v in pairs(workspace:GetDescendants()) do
  29.             if v.Name == 'CoinContainer' then
  30.                 container = v
  31.                 break
  32.             end
  33.         end
  34.     end
  35. end)
  36.  
  37. --/////////////////////////////////////////
  38.  
  39. event = nil
  40. stop = false
  41. event = uis.InputBegan:Connect(function(input,gpe)
  42.     if gpe then return end
  43.     if input.KeyCode == Enum.KeyCode.X then
  44.         stop = true
  45.     end
  46. end)
  47. --/////////////////////////////////////////////////////////
  48.  
  49. function createPath(from,to)
  50.     local agentParams = {
  51.         AgentHeight = 2.5,
  52.         AgentRadius = 2,
  53.         AgentCanJump = true
  54.     }
  55.     local path = pathfinder:CreatePath(agentParams)
  56.     path:ComputeAsync(from,to)
  57.     if path.Status == Enum.PathStatus.Success then
  58.         local waypoints = path:GetWaypoints()
  59.         return path,waypoints
  60.     end
  61. end
  62.  
  63. function waypointLength(waypoints)
  64.     local sum = 0
  65.     local lastpoint
  66.     for i,waypoint in pairs(waypoints) do
  67.         if lastpoint then
  68.             sum = sum + (waypoint.Position - lastpoint.Position).Magnitude
  69.         end
  70.         lastpoint = waypoint
  71.     end
  72.     return sum
  73. end
  74.  
  75. --////////////////////////////////////////////
  76.  
  77. clip = true
  78. function Nocl()
  79.     if game.Players.LocalPlayer.Character ~= nil then
  80.         for _,v in pairs(game.Players.LocalPlayer.Character:GetDescendants()) do
  81.             if v:IsA("BasePart") and (v.CanCollide or v.Name == 'HumanoidRootPart' or v.Name == 'UpperTorso' or v.Name == 'LowerTorso') then
  82.                 v.CanCollide = clip == true and true or false
  83.             end
  84.         end
  85.     end
  86.     wait(0.21) -- basic optimization
  87. end
  88. Noclip = game:GetService('RunService').Stepped:Connect(Nocl)
  89.  
  90. --////////////////////////////////////////////////////////
  91.  
  92. killer = nil
  93. spawn(function()
  94.     while not stop do
  95.         wait()
  96.         for i,plr in pairs(game.Players:GetChildren()) do
  97.             if plr ~= myplr and plr.Character and plr.Character:FindFirstChild('Knife') then
  98.                 killer = plr.Character
  99.             end
  100.         end
  101.     end
  102. end)
  103.  
  104. function killernear()
  105.     if killer and killer.Parent and killer:FindFirstChild('HumanoidRootPart') then
  106.         local dangerdist = (root.Position - killer.HumanoidRootPart.Position).Magnitude
  107.         return dangerdist <= 30
  108.     end
  109.     return false
  110. end
  111.  
  112. function killerinsight()
  113.     if killer and killer.Parent and killer:FindFirstChild('HumanoidRootPart') then
  114.         local params = RaycastParams.new()
  115.         params.FilterType = Enum.RaycastFilterType.Exclude
  116.         params.FilterDescendantsInstances = {myplr.Character}
  117.         local result = workspace:Raycast(root.Position, (killer.HumanoidRootPart.Position - root.Position).Unit*150, params)
  118.         return (result and result.Instance and result.Instance:IsDescendantOf(killer)) and true or false
  119.     end
  120.     return false
  121. end
  122.  
  123. --////////////////////////////////////////////////////////
  124.  
  125. function isInLobby()
  126.     if root and root.Parent then
  127.         local touches = workspace:GetPartBoundsInBox(
  128.             root.CFrame,
  129.             Vector3.new(2,20,2)
  130.         )
  131.         for i,v in pairs(touches) do
  132.             if v:IsDescendantOf(workspace.Lobby) then
  133.                 return true
  134.             end
  135.         end
  136.         return false
  137.     else -- root not found meaning that we just died and havent yet respawned into the lobby
  138.         return true
  139.     end
  140. end
  141.  
  142. function fly(checkkiller)  
  143.     clip = false
  144.  
  145.     local rootpos = root.Position
  146.     local movepos = coin.Position + Vector3.new(0,2,0)
  147.  
  148.     local bg = Instance.new('BodyGyro')
  149.     bg.P = 10000
  150.     bg.MaxTorque = Vector3.new(999999,999999,999999)
  151.     bg.CFrame = CFrame.new(rootpos, movepos)
  152.     bg.Parent = root
  153.     local bv = Instance.new('BodyVelocity')
  154.     bv.MaxForce = Vector3.new(999999,999999,999999)
  155.  
  156.     lastpos = nil
  157.     repeat
  158.         tries = tries + 1
  159.         if tries >= 4 then
  160.             tries = 0
  161.             if lastpos and (rootpos - lastpos).Magnitude < 2 then
  162.                 if lastcoin and lastcoin == coin then
  163.                     coin.Parent = nil -- cursed coin, cannot be collected
  164.                     lastcoin = nil
  165.                     break
  166.                 end
  167.             end
  168.             lastpos = root.Position
  169.         end
  170.        
  171.         bv.Velocity = (movepos - rootpos).Unit*26
  172.         bv.Parent = root
  173.        
  174.         wait(.2)
  175.         local henear = checkkiller and (killernear() or killerinsight())
  176.     until (root.Position - rootpos).Magnitude >= (movepos - rootpos).Magnitude or hum.Health == 0 or stop or henear
  177.     bv:Destroy()
  178.     bg:Destroy()
  179.  
  180.     clip = true
  181.  
  182.     lastcoin = coin
  183. end
  184.  
  185. --////////////////////////////////////////////////////
  186.  
  187. lastpos = nil
  188. lastcoin = nil
  189. tries = 0
  190. coin = nil
  191. cointable = {}
  192. count = 0
  193.  
  194. while not stop do
  195.     local succ, msg = pcall(function()
  196.  
  197.         if myplr.Character and container and container.Parent then
  198.             root = myplr.Character:FindFirstChild('HumanoidRootPart')
  199.             hum = myplr.Character:FindFirstChild('Humanoid')
  200.  
  201.             if root and hum and not isInLobby() then
  202.                 cointable = {}
  203.                 count = 0
  204.                 coin = nil
  205.  
  206.                 for i,v in pairs(container:GetChildren()) do
  207.                     if v:FindFirstChild('Coin') then
  208.                         count = count + 1
  209.                         if table.find(COIN_TYPE, v.CoinType.Value) then
  210.                             local ele = {}
  211.                             ele.obj = v
  212.                             --[[local path, waypoints = createPath(root.Position, v.Position)
  213.                             ele.path = path
  214.                             ele.waypoints = waypoints
  215.                             if path and waypoints then
  216.                                 ele.dist1 = waypointLength(waypoints)
  217.                             else
  218.                                 ele.dist1 = (v.Position - root.Position).Magnitude -- lower priority, therefore degree 2
  219.                             end]]
  220.                             ele.dist1 = (v.Position - root.Position).Magnitude
  221.                             ele.dist2 = (killer and killer.Parent) and (v.Position - killer.HumanoidRootPart.Position).Magnitude or 300
  222.                            
  223.                             table.insert(cointable, ele)
  224.                         end
  225.                     end
  226.                 end
  227.  
  228.                 if not killernear() and not killerinsight() then
  229.                     local mindist = 666
  230.                     local path,waypoints
  231.                     for i,v in pairs(cointable) do
  232.                         if v.dist1 <= mindist and v.dist1 >= 4 and v.dist2 >= 40 then
  233.                             coin = v.obj
  234.                             mindist = v.dist1
  235.                             path = v.path
  236.                             waypoints = v.waypoints
  237.                         end
  238.                     end
  239.  
  240.                     if coin then
  241.                         local path, waypoints = createPath(root.Position, coin.Position)
  242.                         if path and waypoints and killer and killer.Parent then -- if the killer hasnt revealed self yet, its unsafe to run around
  243.                             print'path waypoint'
  244.  
  245.                             clip = false
  246.                             lastpos = nil
  247.                            
  248.                             for i,waypoint in pairs(waypoints) do
  249.                                 if hum.Health == 0 or root.Parent == nil or stop or killernear() or killerinsight() then break end
  250.                                 if i == 1 then continue end
  251.  
  252.                                 local rootpos = root.Position
  253.                                 local movepos = waypoint.Position + Vector3.new(0,3,0)
  254.                                 local movedir = (movepos - rootpos).Unit
  255.  
  256.                                 tries = tries + 1
  257.                                 if tries >= 4 then
  258.                                     tries = 0
  259.                                     if lastpos and (rootpos - lastpos).Magnitude < 1 then
  260.                                         if lastcoin and lastcoin == coin then
  261.                                             coin.Parent = nil -- cursed coin, cannot be collected
  262.                                             lastcoin = nil
  263.                                             break
  264.                                         end
  265.                                     end
  266.                                     lastpos = root.Position
  267.                                 end
  268.                                
  269.  
  270.                                 local bg = Instance.new('BodyGyro')
  271.                                 bg.P = 10000
  272.                                 bg.MaxTorque = Vector3.new(999999,999999,999999)
  273.                                 local bp = Instance.new('BodyPosition')
  274.                                 bp.P = 40000
  275.                                 bp.MaxForce = Vector3.new(999999,999999,999999)
  276.  
  277.                                 bp.Position = movepos
  278.                                 bp.Parent = root
  279.                                 bg.CFrame = CFrame.new(rootpos, movepos)
  280.                                 bg.Parent = root
  281.                                 wait(.15)
  282.                                 bp:Destroy()
  283.                                 bg:Destroy()
  284.                                
  285.                             end
  286.  
  287.                             clip = true
  288.                             lastcoin = coin
  289.  
  290.                         else
  291.                             print'no path'
  292.                             fly(true)
  293.                         end
  294.                     end
  295.                    
  296.                 else
  297.  
  298.                     local maxdist = 0
  299.                     for i,v in pairs(cointable) do
  300.                         if v.dist2 >= maxdist then
  301.                             coin = v.obj
  302.                             maxdist = v.dist2
  303.                         end
  304.                     end
  305.  
  306.                     print'killer near'
  307.                     if count > 0 then -- so we dont teleport down the map when the bag is full
  308.                         clip = false
  309.  
  310.                         local bp = Instance.new('BodyPosition')
  311.                         bp.P = 10000
  312.                         bp.MaxForce = Vector3.new(999999,999999,999999)
  313.                         bp.Position = root.Position + Vector3.new(0,-30,0)  
  314.                         bp.Parent = root
  315.                         wait(1)
  316.                         bp:Destroy()
  317.  
  318.                         clip = true
  319.  
  320.                         if coin then
  321.                             fly()
  322.                         end
  323.                     end
  324.                 end
  325.  
  326.                 if coin == nil and count == 0 then -- either we are in the lobby or that bag is full
  327.                     -- make sure that the below only trigger when bag is full
  328.                     if myplr.Backpack:FindFirstChild('Knife') then
  329.                         -- reset if we're the murderer
  330.                         hum:ChangeState(Enum.HumanoidStateType.Dead)
  331.                     else
  332.                         hasgun = false
  333.                         if myplr.Backpack:FindFirstChild('Gun') then
  334.                             hasgun = true
  335.                         else
  336.                             if workspace:FindFirstChild('GunDrop') then
  337.                                 wait(2)
  338.                                 if workspace:FindFirstChild('GunDrop') then
  339.                                     -- make sure the gun hasnt been stolen by somebody else
  340.                                     repeat
  341.                                         root.CFrame = workspace.GunDrop.CFrame * CFrame.new(0,5,0)
  342.                                         wait()
  343.                                     until myplr.Character:FindFirstChild('Gun') or hum.Health == 0 or workspace:FindFirstChild('GunDrop') == nil
  344.                                     hasgun = true
  345.                                 end
  346.                             end
  347.                         end
  348.  
  349.                         if hasgun and hum.Health > 0 and killer and killer.Parent then
  350.                             -- aim at killer and wait till killer appear in sight
  351.                             myplr.CameraMode = 'LockFirstPerson'
  352.                             --[[repeat
  353.                                 wait()
  354.                             until killerinsight() or hum.Health == 0 or stop]]
  355.  
  356.                             -- spam 1 until equip the gun
  357.                             repeat
  358.                                 vim:SendKeyEvent(true, Enum.KeyCode.One, false, game)
  359.                                 vim:SendKeyEvent(false, Enum.KeyCode.One, false, game)
  360.                                 wait()
  361.                             until myplr.Character:FindFirstChild('Gun') or stop or hum.Health == 0
  362.  
  363.                             wait()
  364.                             myplr.Character.HumanoidRootPart.CFrame = killer.HumanoidRootPart.CFrame * CFrame.new(0,0,6)
  365.                             -- spam shoot until the game ends or we die
  366.                             while hum.Health > 0 and killer and killer.Parent and not stop do
  367.                                 cam.CFrame = CFrame.new(cam.CFrame.p, killer.UpperTorso.Position)
  368.                                 local vp = cam.ViewportSize
  369.                                 vim:SendMouseButtonEvent(vp.X/2,vp.Y/2 , 0, true, game,1)
  370.                                 vim:SendMouseButtonEvent(vp.X/2,vp.Y/2 , 0, false, game,1)
  371.                                 run.Heartbeat:Wait()
  372.                                 vim:SendKeyEvent(true, Enum.KeyCode.One, false, game)
  373.                                 vim:SendKeyEvent(false, Enum.KeyCode.One, false, game)
  374.                             end
  375.                             myplr.CameraMode = 'Classic'
  376.                         end
  377.                     end
  378.                 end
  379.             end
  380.         end
  381.  
  382.     end)
  383.     if not succ then warn(msg) end
  384.  
  385.     wait()
  386. end
  387. event:Disconnect()
  388. Noclip:Disconnect()
  389.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement