Advertisement
aesnike

Untitled

Oct 30th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.63 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local LocalPlayer = Players.LocalPlayer
  3. local Character
  4. local targetNPC
  5. local targetCoin
  6.  
  7. -- Customizable parameters (with default values)
  8. local delay = 0.5
  9. local offset = Vector3.new(0, 9, 0)
  10. local waitTimeIfNoMobs = 2
  11. local coinStayDuration = 5
  12. local mobRange = 25 -- Range for key press activation
  13. local keyPressCooldown = 0.1 --Reduced cooldown
  14.  
  15. -- Save file path (relative to the exploit's workspace)
  16. local saveFilePath = "settings.txt"
  17.  
  18. -- Function to load settings from the save file
  19. local function loadSettings()
  20. local success, data = pcall(function()
  21. return game:GetService("HttpService"):JSONDecode(readfile(saveFilePath))
  22. end)
  23.  
  24. if success and data then
  25. delay = data.delay or delay
  26. offset = Vector3.new(data.offsetX or offset.X, data.offsetY or offset.Y, data.offsetZ or offset.Z)
  27. waitTimeIfNoMobs = data.waitTimeIfNoMobs or waitTimeIfNoMobs
  28. coinStayDuration = data.coinStayDuration or coinStayDuration
  29. mobRange = data.mobRange or mobRange
  30. keyPressCooldown = data.keyPressCooldown or keyPressCooldown
  31. end
  32. end
  33.  
  34. -- Function to save settings to the save file
  35. local function saveSettings()
  36. local data = {
  37. delay = delay,
  38. offsetX = offset.X,
  39. offsetY = offset.Y,
  40. offsetZ = offset.Z,
  41. waitTimeIfNoMobs = waitTimeIfNoMobs,
  42. coinStayDuration = coinStayDuration,
  43. mobRange = mobRange,
  44. keyPressCooldown = keyPressCooldown
  45. }
  46.  
  47. local success, message = pcall(function()
  48. writefile(saveFilePath, game:GetService("HttpService"):JSONEncode(data))
  49. end)
  50.  
  51. if not success then
  52. warn("Error saving settings:", message)
  53. end
  54. end
  55.  
  56. -- Load settings on script start
  57. loadSettings()
  58.  
  59. -- Remote Event setup
  60. local dataRemoteEvent = game:GetService("ReplicatedStorage").dataRemoteEvent
  61. local changeStartValueRemote = game:GetService("ReplicatedStorage").remotes.changeStartValue
  62. local retryVote = LocalPlayer.PlayerGui:WaitForChild("RetryVote")
  63. local revivePrompt = LocalPlayer.PlayerGui:WaitForChild("RevivePrompt")
  64. local startButton = LocalPlayer.PlayerGui:WaitForChild("HUD"):WaitForChild("Mobile"):WaitForChild("StartButton")
  65.  
  66. local voteArgs = {
  67. [1] = {
  68. [1] = {
  69. ["\3"] = "vote",
  70. ["vote"] = true
  71. },
  72. [2] = "."
  73. }
  74. }
  75.  
  76. local reviveArgs = {
  77. [1] = {
  78. [1] = {
  79. ["\3"] = "closeRevive"
  80. },
  81. [2] = "\13"
  82. }
  83. }
  84.  
  85. -- Function to find the nearest NPC (modified)
  86. local function findNearestNPC()
  87. local nearestNPC = nil
  88. local nearestDistance = math.huge
  89.  
  90. Character = LocalPlayer.Character
  91. if not Character or not Character.HumanoidRootPart then return end
  92.  
  93. local dungeon = workspace:FindFirstChild("dungeon")
  94. if not dungeon then return end
  95.  
  96. for _, child in ipairs(dungeon:GetChildren()) do
  97. if child:FindFirstChild("enemyFolder") then
  98. for _, npc in ipairs(child.enemyFolder:GetChildren()) do
  99. if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
  100. local distance = (Character.HumanoidRootPart.Position - npc.HumanoidRootPart.Position).Magnitude
  101. if distance < nearestDistance then
  102. nearestDistance = distance
  103. nearestNPC = npc
  104. end
  105. end
  106. end
  107. end
  108. end
  109. return nearestNPC
  110. end
  111.  
  112. -- Function to find the nearest coin
  113. local function findNearestCoin()
  114. local nearestCoin = nil
  115. local nearestDistance = math.huge
  116.  
  117. Character = LocalPlayer.Character
  118. if not Character or not Character.HumanoidRootPart then return end
  119.  
  120. for _, descendant in ipairs(workspace:GetDescendants()) do
  121. if descendant.Name == "Coin" and descendant:IsA("BasePart") then
  122. local distance = (Character.HumanoidRootPart.Position - descendant.Position).Magnitude
  123. if distance < nearestDistance then
  124. nearestDistance = distance
  125. nearestCoin = descendant
  126. end
  127. end
  128. end
  129. return nearestCoin
  130. end
  131.  
  132. local coinTouchedTime = 0
  133.  
  134. local function stayOnTopOfTarget()
  135. -- Prioritize coins
  136. if targetCoin and targetCoin.Parent then
  137. if Character and Character:FindFirstChild("HumanoidRootPart") then
  138. Character.HumanoidRootPart.CFrame = targetCoin.CFrame
  139.  
  140. if coinTouchedTime == 0 then
  141. coinTouchedTime = tick()
  142. end
  143.  
  144. if tick() - coinTouchedTime > coinStayDuration then
  145. targetCoin = nil
  146. coinTouchedTime = 0
  147. end
  148. end
  149. elseif not targetNPC or not targetNPC.Parent or not targetNPC:FindFirstChild("HumanoidRootPart") then
  150. targetNPC = findNearestNPC()
  151. if not targetNPC then
  152. wait(waitTimeIfNoMobs)
  153. return
  154. end
  155. elseif Character and Character:FindFirstChild("HumanoidRootPart") and targetNPC and targetNPC:FindFirstChild("HumanoidRootPart") and targetNPC:IsDescendantOf(workspace.dungeon) then
  156. local npcPosition = targetNPC.HumanoidRootPart.Position
  157. local lookVector = (npcPosition - Character.HumanoidRootPart.Position).Unit
  158. local cframe = CFrame.new(npcPosition + offset, npcPosition)
  159. Character.HumanoidRootPart.CFrame = cframe
  160. end
  161. end
  162.  
  163. -- CharacterAdded Connection
  164. LocalPlayer.CharacterAdded:Connect(function(newCharacter)
  165. Character = newCharacter
  166. targetNPC = nil
  167. targetCoin = nil
  168. wait(1)
  169. end)
  170.  
  171. -- Key press logic
  172. local UserInputService = game:GetService("UserInputService")
  173. local VirtualInputManager = game:GetService("VirtualInputManager")
  174. local lastKeyPress = 0
  175.  
  176.  
  177. local function isNearMobs(range)
  178. Character = LocalPlayer.Character
  179. if not Character or not Character.HumanoidRootPart then return false end
  180.  
  181. local dungeon = workspace:FindFirstChild("dungeon")
  182. if not dungeon then return false end
  183.  
  184. for _, child in ipairs(dungeon:GetChildren()) do
  185. if child:FindFirstChild("enemyFolder") then
  186. for _, npc in ipairs(child.enemyFolder:GetChildren()) do
  187. if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
  188. local distance = (Character.HumanoidRootPart.Position - npc.HumanoidRootPart.Position).Magnitude
  189. if distance <= range then
  190. return true
  191. end
  192. end
  193. end
  194. end
  195. end
  196. return false
  197. end
  198.  
  199. local function pressKey(key)
  200. VirtualInputManager:SendKeyEvent(true, key, false, nil)
  201. VirtualInputManager:SendKeyEvent(false, key, false, nil)
  202. end
  203.  
  204. -- Main Heartbeat loop
  205. local lastTeleportTime = 0
  206. game:GetService("RunService").Heartbeat:Connect(function()
  207. stayOnTopOfTarget()
  208.  
  209. local currentTime = tick()
  210. if currentTime - lastTeleportTime >= delay then
  211. lastTeleportTime = currentTime
  212. targetCoin = findNearestCoin()
  213. if not targetCoin then
  214. targetNPC = findNearestNPC()
  215. end
  216.  
  217. -- Fire remote events based on GUI state
  218. if retryVote and retryVote.Enabled then
  219. dataRemoteEvent:FireServer(unpack(voteArgs))
  220. end
  221.  
  222. if revivePrompt and revivePrompt.Enabled then
  223. dataRemoteEvent:FireServer(unpack(reviveArgs))
  224. end
  225.  
  226. -- Fire changeStartValue if StartButton is visible
  227. if startButton.Visible then
  228. changeStartValueRemote:FireServer()
  229. end
  230.  
  231. -- Key press logic
  232. if isNearMobs(mobRange) and tick() - lastKeyPress >= keyPressCooldown then
  233. pressKey("E")
  234. pressKey("Q")
  235. lastKeyPress = tick()
  236. end
  237. end
  238. end)
  239.  
  240. -- Initialize
  241. targetCoin = findNearestCoin()
  242. if not targetCoin then
  243. targetNPC = findNearestNPC()
  244. end
  245.  
  246. -- Separate loop to send animation data
  247. coroutine.wrap(function()
  248. while true do
  249. local args = {
  250. [1] = {
  251. [1] = {
  252. ["animationLength"] = 0,
  253. ["sentAt"] = tick()
  254. },
  255. [2] = "G"
  256. }
  257. }
  258.  
  259. game:GetService("ReplicatedStorage").dataRemoteEvent:FireServer(unpack(args))
  260. wait(0)
  261. end
  262. end)()
  263.  
  264. -- Mobile GUI creation
  265. local MobileGui = Instance.new("ScreenGui")
  266. MobileGui.Name = "SettingsGUI"
  267. MobileGui.Parent = LocalPlayer.PlayerGui
  268.  
  269. -- Delay setting
  270. local DelayLabel = Instance.new("TextLabel")
  271. DelayLabel.Text = "Delay:"
  272. DelayLabel.Position = UDim2.new(0.1, 0, 0.1, 0)
  273. DelayLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
  274. DelayLabel.Parent = MobileGui
  275.  
  276. local DelayTextBox = Instance.new("TextBox")
  277. DelayTextBox.Text = tostring(delay)
  278. DelayTextBox.Position = UDim2.new(0.3, 0, 0.1, 0)
  279. DelayTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
  280. DelayTextBox.Parent = MobileGui
  281.  
  282. DelayTextBox.FocusLost:Connect(function(enterPressed)
  283. if enterPressed then
  284. local newDelay = tonumber(DelayTextBox.Text)
  285. if newDelay then
  286. delay = newDelay
  287. saveSettings()
  288. end
  289. end
  290. end)
  291.  
  292. -- Offset X setting
  293. local OffsetXLabel = Instance.new("TextLabel")
  294. OffsetXLabel.Text = "Offset X:"
  295. OffsetXLabel.Position = UDim2.new(0.1, 0, 0.16, 0)
  296. OffsetXLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
  297. OffsetXLabel.Parent = MobileGui
  298.  
  299. local OffsetXTextBox = Instance.new("TextBox")
  300. OffsetXTextBox.Text = tostring(offset.X)
  301. OffsetXTextBox.Position = UDim2.new(0.3, 0, 0.16, 0)
  302. OffsetXTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
  303. OffsetXTextBox.Parent = MobileGui
  304.  
  305. OffsetXTextBox.FocusLost:Connect(function(enterPressed)
  306. if enterPressed then
  307. local newOffsetX = tonumber(OffsetXTextBox.Text)
  308. if newOffsetX then
  309. offset = Vector3.new(newOffsetX, offset.Y, offset.Z)
  310. saveSettings()
  311. end
  312. end
  313. end)
  314.  
  315. -- Offset Y setting
  316. local OffsetYLabel = Instance.new("TextLabel")
  317. OffsetYLabel.Text = "Offset Y:"
  318. OffsetYLabel.Position = UDim2.new(0.1, 0, 0.22, 0)
  319. OffsetYLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
  320. OffsetYLabel.Parent = MobileGui
  321.  
  322. local OffsetYTextBox = Instance.new("TextBox")
  323. OffsetYTextBox.Text = tostring(offset.Y)
  324. OffsetYTextBox.Position = UDim2.new(0.3, 0, 0.22, 0)
  325. OffsetYTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
  326. OffsetYTextBox.Parent = MobileGui
  327.  
  328. OffsetYTextBox.FocusLost:Connect(function(enterPressed)
  329. if enterPressed then
  330. local newOffsetY = tonumber(OffsetYTextBox.Text)
  331. if newOffsetY then
  332. offset = Vector3.new(offset.X, newOffsetY, offset.Z)
  333. saveSettings()
  334. end
  335. end
  336. end)
  337.  
  338. -- Offset Z setting
  339. local OffsetZLabel = Instance.new("TextLabel")
  340. OffsetZLabel.Text = "Offset Z:"
  341. OffsetZLabel.Position = UDim2.new(0.1, 0, 0.28, 0)
  342. OffsetZLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
  343. OffsetZLabel.Parent = MobileGui
  344.  
  345. local OffsetZTextBox = Instance.new("TextBox")
  346. OffsetZTextBox.Text = tostring(offset.Z)
  347. OffsetZTextBox.Position = UDim2.new(0.3, 0, 0.28, 0)
  348. OffsetZTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
  349. OffsetZTextBox.Parent = MobileGui
  350.  
  351. OffsetZTextBox.FocusLost:Connect(function(enterPressed)
  352. if enterPressed then
  353. local newOffsetZ = tonumber(OffsetZTextBox.Text)
  354. if newOffsetZ then
  355. offset = Vector3.new(offset.X, offset.Y, newOffsetZ)
  356. saveSettings()
  357. end
  358. end
  359. end)
  360.  
  361. -- Wait Time If No Mobs setting
  362. local WaitTimeLabel = Instance.new("TextLabel")
  363. WaitTimeLabel.Text = "Wait Time (No Mobs):"
  364. WaitTimeLabel.Position = UDim2.new(0.1, 0, 0.34, 0)
  365. WaitTimeLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
  366. WaitTimeLabel.Parent = MobileGui
  367.  
  368. local WaitTimeTextBox = Instance.new("TextBox")
  369. WaitTimeTextBox.Text = tostring(waitTimeIfNoMobs)
  370. WaitTimeTextBox.Position = UDim2.new(0.3, 0, 0.34, 0)
  371. WaitTimeTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
  372. WaitTimeTextBox.Parent = MobileGui
  373.  
  374. WaitTimeTextBox.FocusLost:Connect(function(enterPressed)
  375. if enterPressed then
  376. local newWaitTime = tonumber(WaitTimeTextBox.Text)
  377. if newWaitTime then
  378. waitTimeIfNoMobs = newWaitTime
  379. saveSettings()
  380. end
  381. end
  382. end)
  383.  
  384. -- Coin Stay Duration setting
  385. local CoinDurationLabel = Instance.new("TextLabel")
  386. CoinDurationLabel.Text = "Coin Stay Duration:"
  387. CoinDurationLabel.Position = UDim2.new(0.1, 0, 0.4, 0)
  388. CoinDurationLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
  389. CoinDurationLabel.Parent = MobileGui
  390.  
  391. local CoinDurationTextBox = Instance.new("TextBox")
  392. CoinDurationTextBox.Text = tostring(coinStayDuration)
  393. CoinDurationTextBox.Position = UDim2.new(0.3, 0, 0.4, 0)
  394. CoinDurationTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
  395. CoinDurationTextBox.Parent = MobileGui
  396.  
  397. CoinDurationTextBox.FocusLost:Connect(function(enterPressed)
  398. if enterPressed then
  399. local newDuration = tonumber(CoinDurationTextBox.Text)
  400. if newDuration then
  401. coinStayDuration = newDuration
  402. saveSettings()
  403. end
  404. end
  405. end)
  406.  
  407. -- Mob Range setting
  408. local MobRangeLabel = Instance.new("TextLabel")
  409. MobRangeLabel.Text = "Mob Range:"
  410. MobRangeLabel.Position = UDim2.new(0.1, 0, 0.46, 0)
  411. MobRangeLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
  412. MobRangeLabel.Parent = MobileGui
  413.  
  414. local MobRangeTextBox = Instance.new("TextBox")
  415. MobRangeTextBox.Text = tostring(mobRange)
  416. MobRangeTextBox.Position = UDim2.new(0.3, 0, 0.46, 0)
  417. MobRangeTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
  418. MobRangeTextBox.Parent = MobileGui
  419.  
  420. MobRangeTextBox.FocusLost:Connect(function(enterPressed)
  421. if enterPressed then
  422. local newRange = tonumber(MobRangeTextBox.Text)
  423. if newRange then
  424. mobRange = newRange
  425. saveSettings()
  426. end
  427. end
  428. end)
  429.  
  430. --KeyPress Cooldown Setting
  431. local KeyPressCooldownLabel = Instance.new("TextLabel")
  432. KeyPressCooldownLabel.Text = "Keypress Cooldown:"
  433. KeyPressCooldownLabel.Position = UDim2.new(0.1, 0, 0.52, 0)
  434. KeyPressCooldownLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
  435. KeyPressCooldownLabel.Parent = MobileGui
  436.  
  437. local KeyPressCooldownTextBox = Instance.new("TextBox")
  438. KeyPressCooldownTextBox.Text = tostring(keyPressCooldown)
  439. KeyPressCooldownTextBox.Position = UDim2.new(0.3, 0, 0.52, 0)
  440. KeyPressCooldownTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
  441. KeyPressCooldownTextBox.Parent = MobileGui
  442.  
  443. KeyPressCooldownTextBox.FocusLost:Connect(function(enterPressed)
  444. if enterPressed then
  445. local newCooldown = tonumber(KeyPressCooldownTextBox.Text)
  446. if newCooldown then
  447. keyPressCooldown = newCooldown
  448. saveSettings()
  449. end
  450. end
  451. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement