Advertisement
anphu04

Murder Mystery 2 - FARM COINS

Aug 29th, 2023 (edited)
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.34 KB | None | 0 0
  1. -- 28/2/2023: last exploit(s) before going home tomorrow
  2. COIN_TYPE = {'BeachBall'}
  3.  
  4. local container
  5. for i,v in pairs(workspace:GetDescendants()) do
  6.     if v.Name == 'CoinContainer' then
  7.         container = v
  8.         break
  9.     end
  10. end
  11.  
  12. myplr = game.Players.LocalPlayer
  13. uis = game:GetService('UserInputService')
  14. pathfinder = game:GetService('PathfindingService')
  15. tweener = game:GetService('TweenService')
  16.  
  17. local event
  18. local stop = false
  19. event = uis.InputBegan:Connect(function(input,gpe)
  20.     if gpe then return end
  21.     if input.KeyCode == Enum.KeyCode.X then
  22.         stop = true
  23.     end
  24. end)
  25. --/////////////////////////////////////////////////////////
  26.  
  27. function createPath(from,to)
  28.     local agentParams = {
  29.         AgentHeight = 2.5,
  30.         AgentRadius = 2,
  31.         AgentCanJump = true
  32.     }
  33.     local path = pathfinder:CreatePath(agentParams)
  34.     path:ComputeAsync(from,to)
  35.     if path.Status == Enum.PathStatus.Success then
  36.         local waypoints = path:GetWaypoints()
  37.         return path,waypoints
  38.     end
  39. end
  40.  
  41. function insight(from,target) -- make sure no players see us or we'll be accused of cheating
  42.     for i,plr in pairs(game.Players:GetChildren()) do
  43.         if plr ~= myplr then
  44.             local params = RaycastParams.new()
  45.             params.FilterType = Enum.RaycastFilterType.Exclude
  46.             params.FilterDescendantsInstances = {myplr.Character}
  47.  
  48.             local result = workspace:Raycast(from, (target.Position-from).Unit*150, params)
  49.             if result and result.Instance then
  50.                 if result.Instance == target or result.Instance:IsDescendantOf(target) then
  51.                     return true
  52.                 end
  53.             end
  54.  
  55.         end
  56.     end
  57. end
  58.  
  59. function noclip()
  60.     for _,v in pairs(myplr.Character:GetDescendants()) do
  61.         if v:IsA('BasePart') and v.CanCollide then
  62.             v.CanCollide = false
  63.         end
  64.     end
  65. end
  66.  
  67. lastpos = nil
  68.  
  69. while not stop do
  70.     if myplr.Character then
  71.         root = myplr.Character:FindFirstChild('HumanoidRootPart')
  72.         hum = myplr.Character:FindFirstChild('Humanoid')
  73.         if root and hum then
  74.  
  75.             local coin
  76.             local dist = 300
  77.  
  78.             for i,v in pairs(container:GetChildren()) do
  79.                 if v:FindFirstChild('Coin') and table.find(COIN_TYPE, v.CoinType.Value)  then -- hasnt been collected
  80.                     if insight(root.Position, v) then
  81.                         if (v.Position - root.Position).Magnitude < dist then
  82.                             coin = v
  83.                             dist = (v.Position - root.Position).Magnitude
  84.                         end
  85.                     end
  86.                 end
  87.             end
  88.             -- if no coin is insight then find the nearest coin without that condition
  89.             dist = 300
  90.             if coin == nil then
  91.                 for i,v in pairs(container:GetChildren()) do
  92.                     if v:FindFirstChild('Coin') and table.find(COIN_TYPE, v.CoinType.Value) then -- hasnt been collected
  93.                         if (v.Position - root.Position).Magnitude < dist then
  94.                             coin = v
  95.                             dist = (v.Position - root.Position).Magnitude
  96.                         end
  97.                     end
  98.                 end
  99.             end
  100.  
  101.  
  102.             if math.random(1,10) == 1 then
  103.                 hum:MoveTo(root.Position + Vector3.new(math.random(-8,8),0,math.random(-8,8)))
  104.                 hum.Jump = true
  105.             end
  106.  
  107.             local path,waypoints = createPath(root.Position, coin.Position)
  108.             if path and waypoints then
  109.                 local bg = Instance.new('BodyGyro')
  110.                 bg.P = 10000
  111.                 bg.MaxTorque = Vector3.new(99999,99999,99999)
  112.                 local bp = Instance.new('BodyPosition')
  113.                 bp.P = 40000
  114.                 bp.MaxForce = Vector3.new(999999,999999,999999)
  115.                
  116.                 for i,waypoint in pairs(waypoints) do
  117.                     if i == 1 then continue end
  118.                     if hum.Health == 0 or root.Parent == nil or stop then break end
  119.  
  120.                     local rootpos = root.Position
  121.                     local movepos = waypoint.Position + Vector3.new(0,2,0)
  122.                     local movedir = (movepos - rootpos).Unit
  123.                    
  124.                     if lastpos and (rootpos - lastpos).Magnitude < .1 then
  125.                         break -- meaning we are stuck
  126.                     end
  127.  
  128.                    
  129.  
  130.                     if waypoint.Action == Enum.PathWaypointAction.Jump then
  131.                         hum.Jump = true
  132.                     end
  133.  
  134.                     --[[local lookpos = Vector3.new(movepos.X, rootpos.Y, movepos.Z)
  135.                     local rootcf = CFrame.new(rootpos)
  136.                     for i = 0,1,1/3 do
  137.                         root.CFrame = rootcf:Lerp(CFrame.new(movepos), i)
  138.                     end]]
  139.                    
  140.                     bp.Position = movepos
  141.                     bp.Parent = root
  142.                     bg.CFrame = CFrame.new(rootpos, movepos)
  143.                     bg.Parent = root
  144.                     noclip()
  145.                     wait(.15)
  146.                    
  147.                     lastpos = movepos
  148.                 end
  149.                 bp:Destroy()
  150.                 bg:Destroy()
  151.             end
  152.         end
  153.     end
  154.     wait()
  155. end
  156. event:Disconnect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement