Advertisement
Guest User

Weapon Fighting Simulator - Working Autofarm

a guest
Jan 29th, 2022
8,162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. -- Script made by BoredScripter on yt
  2. _G.Toggle = true
  3. _G.chosenType = "Low Health" -- only 'Low Health' type works atm
  4.  
  5.  
  6. local farmTypes = {"Nearest", "Low Health", "High Health"}
  7.  
  8. local workspace = game:GetService("Workspace")
  9. local chestsF = workspace.Fight.Chests
  10. local clientChestsF = workspace.Fight.ClientChests
  11. local swordModelsF = workspace.Fight.Pets
  12.  
  13. local plr = game.Players.LocalPlayer
  14. local userID = plr.UserId
  15. local character = plr.character
  16. local root = character.HumanoidRootPart
  17. local startPosition = root.CFrame
  18. local rs = game:GetService("RunService")
  19.  
  20. local function Teleport(Root, Part)
  21.     Root.CFrame = Part.CFrame * CFrame.new(0,-15,0)
  22. end
  23.  
  24. local function findChest(chosenType)
  25.     local num = math.huge
  26.     local currentChest
  27.     for i,v in pairs(clientChestsF:GetChildren()) do
  28.         v = chestsF:FindFirstChild(v.Name).ChestHpMax
  29.         if v.Value < num then
  30.             num = v.Value
  31.             currentChest = clientChestsF:FindFirstChild(v.Parent.Name)
  32.         elseif v.Value == num then
  33.             print(v.Parent.Name)
  34.             local secondChest = clientChestsF:FindFirstChild(v.Parent.Name)
  35.  
  36.             local currentMagnitude = (currentChest.Root.Position - root.Position).Magnitude
  37.             local newMagnitude = (secondChest.Root.Position - root.Position).Magnitude
  38.                
  39.             if newMagnitude < currentMagnitude then
  40.                 num = v.Value
  41.                 currentChest = clientChestsF:FindFirstChild(v.Parent.Name)
  42.             end
  43.         end
  44.     end
  45.     return currentChest
  46. end
  47.  
  48. print(findChest(_G.chosenType))
  49.  
  50. while _G.Toggle do
  51.     local chest = findChest(_G.chosenType)
  52.     local events = workspace.Fight.Events
  53.     local chHP = chestsF:FindFirstChild(chest.Name).ChestHp
  54.     local args = {[1] = 0, [2] = chest.Name}
  55.     repeat
  56.         Teleport(root, chest.Root)
  57.         print(chest.Root)
  58.         local currentSwordTarget = swordModelsF:FindFirstChild(userID.."_pets"):FindFirstChildWhichIsA("Model").PetTarget
  59.         if currentSwordTarget.Value ~= chest.Name then
  60.             events.FightAttack:InvokeServer(unpack(args))
  61.             print("fired invoke", unpack(args))
  62.         end
  63.         for _,pr in pairs(game:GetService("Workspace").Rewards:GetChildren()) do
  64.             pr.CFrame = root.CFrame
  65.         end
  66.         rs.Heartbeat:Wait()
  67.     until not _G.Toggle or chest.Parent ~= clientChestsF
  68.     print("Dead")
  69. end
  70.  
  71. root.CFrame = startPosition
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement