Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- local Character
- local targetNPC
- local targetCoin
- -- Customizable parameters (with default values)
- local delay = 0.5
- local offset = Vector3.new(0, 9, 0)
- local waitTimeIfNoMobs = 2
- local coinStayDuration = 5
- local mobRange = 25 -- Range for key press activation
- local keyPressCooldown = 0.1 --Reduced cooldown
- -- Save file path (relative to the exploit's workspace)
- local saveFilePath = "settings.txt"
- -- Function to load settings from the save file
- local function loadSettings()
- local success, data = pcall(function()
- return game:GetService("HttpService"):JSONDecode(readfile(saveFilePath))
- end)
- if success and data then
- delay = data.delay or delay
- offset = Vector3.new(data.offsetX or offset.X, data.offsetY or offset.Y, data.offsetZ or offset.Z)
- waitTimeIfNoMobs = data.waitTimeIfNoMobs or waitTimeIfNoMobs
- coinStayDuration = data.coinStayDuration or coinStayDuration
- mobRange = data.mobRange or mobRange
- keyPressCooldown = data.keyPressCooldown or keyPressCooldown
- end
- end
- -- Function to save settings to the save file
- local function saveSettings()
- local data = {
- delay = delay,
- offsetX = offset.X,
- offsetY = offset.Y,
- offsetZ = offset.Z,
- waitTimeIfNoMobs = waitTimeIfNoMobs,
- coinStayDuration = coinStayDuration,
- mobRange = mobRange,
- keyPressCooldown = keyPressCooldown
- }
- local success, message = pcall(function()
- writefile(saveFilePath, game:GetService("HttpService"):JSONEncode(data))
- end)
- if not success then
- warn("Error saving settings:", message)
- end
- end
- -- Load settings on script start
- loadSettings()
- -- Remote Event setup
- local dataRemoteEvent = game:GetService("ReplicatedStorage").dataRemoteEvent
- local changeStartValueRemote = game:GetService("ReplicatedStorage").remotes.changeStartValue
- local retryVote = LocalPlayer.PlayerGui:WaitForChild("RetryVote")
- local revivePrompt = LocalPlayer.PlayerGui:WaitForChild("RevivePrompt")
- local startButton = LocalPlayer.PlayerGui:WaitForChild("HUD"):WaitForChild("Mobile"):WaitForChild("StartButton")
- local voteArgs = {
- [1] = {
- [1] = {
- ["\3"] = "vote",
- ["vote"] = true
- },
- [2] = "."
- }
- }
- local reviveArgs = {
- [1] = {
- [1] = {
- ["\3"] = "closeRevive"
- },
- [2] = "\13"
- }
- }
- -- Function to find the nearest NPC (modified)
- local function findNearestNPC()
- local nearestNPC = nil
- local nearestDistance = math.huge
- Character = LocalPlayer.Character
- if not Character or not Character.HumanoidRootPart then return end
- local dungeon = workspace:FindFirstChild("dungeon")
- if not dungeon then return end
- for _, child in ipairs(dungeon:GetChildren()) do
- if child:FindFirstChild("enemyFolder") then
- for _, npc in ipairs(child.enemyFolder:GetChildren()) do
- if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
- local distance = (Character.HumanoidRootPart.Position - npc.HumanoidRootPart.Position).Magnitude
- if distance < nearestDistance then
- nearestDistance = distance
- nearestNPC = npc
- end
- end
- end
- end
- end
- return nearestNPC
- end
- -- Function to find the nearest coin
- local function findNearestCoin()
- local nearestCoin = nil
- local nearestDistance = math.huge
- Character = LocalPlayer.Character
- if not Character or not Character.HumanoidRootPart then return end
- for _, descendant in ipairs(workspace:GetDescendants()) do
- if descendant.Name == "Coin" and descendant:IsA("BasePart") then
- local distance = (Character.HumanoidRootPart.Position - descendant.Position).Magnitude
- if distance < nearestDistance then
- nearestDistance = distance
- nearestCoin = descendant
- end
- end
- end
- return nearestCoin
- end
- local coinTouchedTime = 0
- local function stayOnTopOfTarget()
- -- Prioritize coins
- if targetCoin and targetCoin.Parent then
- if Character and Character:FindFirstChild("HumanoidRootPart") then
- Character.HumanoidRootPart.CFrame = targetCoin.CFrame
- if coinTouchedTime == 0 then
- coinTouchedTime = tick()
- end
- if tick() - coinTouchedTime > coinStayDuration then
- targetCoin = nil
- coinTouchedTime = 0
- end
- end
- elseif not targetNPC or not targetNPC.Parent or not targetNPC:FindFirstChild("HumanoidRootPart") then
- targetNPC = findNearestNPC()
- if not targetNPC then
- wait(waitTimeIfNoMobs)
- return
- end
- elseif Character and Character:FindFirstChild("HumanoidRootPart") and targetNPC and targetNPC:FindFirstChild("HumanoidRootPart") and targetNPC:IsDescendantOf(workspace.dungeon) then
- local npcPosition = targetNPC.HumanoidRootPart.Position
- local lookVector = (npcPosition - Character.HumanoidRootPart.Position).Unit
- local cframe = CFrame.new(npcPosition + offset, npcPosition)
- Character.HumanoidRootPart.CFrame = cframe
- end
- end
- -- CharacterAdded Connection
- LocalPlayer.CharacterAdded:Connect(function(newCharacter)
- Character = newCharacter
- targetNPC = nil
- targetCoin = nil
- wait(1)
- end)
- -- Key press logic
- local UserInputService = game:GetService("UserInputService")
- local VirtualInputManager = game:GetService("VirtualInputManager")
- local lastKeyPress = 0
- local function isNearMobs(range)
- Character = LocalPlayer.Character
- if not Character or not Character.HumanoidRootPart then return false end
- local dungeon = workspace:FindFirstChild("dungeon")
- if not dungeon then return false end
- for _, child in ipairs(dungeon:GetChildren()) do
- if child:FindFirstChild("enemyFolder") then
- for _, npc in ipairs(child.enemyFolder:GetChildren()) do
- if npc:FindFirstChild("HumanoidRootPart") and npc:FindFirstChild("Humanoid") and npc.Humanoid.Health > 0 then
- local distance = (Character.HumanoidRootPart.Position - npc.HumanoidRootPart.Position).Magnitude
- if distance <= range then
- return true
- end
- end
- end
- end
- end
- return false
- end
- local function pressKey(key)
- VirtualInputManager:SendKeyEvent(true, key, false, nil)
- VirtualInputManager:SendKeyEvent(false, key, false, nil)
- end
- -- Main Heartbeat loop
- local lastTeleportTime = 0
- game:GetService("RunService").Heartbeat:Connect(function()
- stayOnTopOfTarget()
- local currentTime = tick()
- if currentTime - lastTeleportTime >= delay then
- lastTeleportTime = currentTime
- targetCoin = findNearestCoin()
- if not targetCoin then
- targetNPC = findNearestNPC()
- end
- -- Fire remote events based on GUI state
- if retryVote and retryVote.Enabled then
- dataRemoteEvent:FireServer(unpack(voteArgs))
- end
- if revivePrompt and revivePrompt.Enabled then
- dataRemoteEvent:FireServer(unpack(reviveArgs))
- end
- -- Fire changeStartValue if StartButton is visible
- if startButton.Visible then
- changeStartValueRemote:FireServer()
- end
- -- Key press logic
- if isNearMobs(mobRange) and tick() - lastKeyPress >= keyPressCooldown then
- pressKey("E")
- pressKey("Q")
- lastKeyPress = tick()
- end
- end
- end)
- -- Initialize
- targetCoin = findNearestCoin()
- if not targetCoin then
- targetNPC = findNearestNPC()
- end
- -- Separate loop to send animation data
- coroutine.wrap(function()
- while true do
- local args = {
- [1] = {
- [1] = {
- ["animationLength"] = 0,
- ["sentAt"] = tick()
- },
- [2] = "G"
- }
- }
- game:GetService("ReplicatedStorage").dataRemoteEvent:FireServer(unpack(args))
- wait(0)
- end
- end)()
- -- Mobile GUI creation
- local MobileGui = Instance.new("ScreenGui")
- MobileGui.Name = "SettingsGUI"
- MobileGui.Parent = LocalPlayer.PlayerGui
- -- Delay setting
- local DelayLabel = Instance.new("TextLabel")
- DelayLabel.Text = "Delay:"
- DelayLabel.Position = UDim2.new(0.1, 0, 0.1, 0)
- DelayLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
- DelayLabel.Parent = MobileGui
- local DelayTextBox = Instance.new("TextBox")
- DelayTextBox.Text = tostring(delay)
- DelayTextBox.Position = UDim2.new(0.3, 0, 0.1, 0)
- DelayTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
- DelayTextBox.Parent = MobileGui
- DelayTextBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local newDelay = tonumber(DelayTextBox.Text)
- if newDelay then
- delay = newDelay
- saveSettings()
- end
- end
- end)
- -- Offset X setting
- local OffsetXLabel = Instance.new("TextLabel")
- OffsetXLabel.Text = "Offset X:"
- OffsetXLabel.Position = UDim2.new(0.1, 0, 0.16, 0)
- OffsetXLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
- OffsetXLabel.Parent = MobileGui
- local OffsetXTextBox = Instance.new("TextBox")
- OffsetXTextBox.Text = tostring(offset.X)
- OffsetXTextBox.Position = UDim2.new(0.3, 0, 0.16, 0)
- OffsetXTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
- OffsetXTextBox.Parent = MobileGui
- OffsetXTextBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local newOffsetX = tonumber(OffsetXTextBox.Text)
- if newOffsetX then
- offset = Vector3.new(newOffsetX, offset.Y, offset.Z)
- saveSettings()
- end
- end
- end)
- -- Offset Y setting
- local OffsetYLabel = Instance.new("TextLabel")
- OffsetYLabel.Text = "Offset Y:"
- OffsetYLabel.Position = UDim2.new(0.1, 0, 0.22, 0)
- OffsetYLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
- OffsetYLabel.Parent = MobileGui
- local OffsetYTextBox = Instance.new("TextBox")
- OffsetYTextBox.Text = tostring(offset.Y)
- OffsetYTextBox.Position = UDim2.new(0.3, 0, 0.22, 0)
- OffsetYTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
- OffsetYTextBox.Parent = MobileGui
- OffsetYTextBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local newOffsetY = tonumber(OffsetYTextBox.Text)
- if newOffsetY then
- offset = Vector3.new(offset.X, newOffsetY, offset.Z)
- saveSettings()
- end
- end
- end)
- -- Offset Z setting
- local OffsetZLabel = Instance.new("TextLabel")
- OffsetZLabel.Text = "Offset Z:"
- OffsetZLabel.Position = UDim2.new(0.1, 0, 0.28, 0)
- OffsetZLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
- OffsetZLabel.Parent = MobileGui
- local OffsetZTextBox = Instance.new("TextBox")
- OffsetZTextBox.Text = tostring(offset.Z)
- OffsetZTextBox.Position = UDim2.new(0.3, 0, 0.28, 0)
- OffsetZTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
- OffsetZTextBox.Parent = MobileGui
- OffsetZTextBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local newOffsetZ = tonumber(OffsetZTextBox.Text)
- if newOffsetZ then
- offset = Vector3.new(offset.X, offset.Y, newOffsetZ)
- saveSettings()
- end
- end
- end)
- -- Wait Time If No Mobs setting
- local WaitTimeLabel = Instance.new("TextLabel")
- WaitTimeLabel.Text = "Wait Time (No Mobs):"
- WaitTimeLabel.Position = UDim2.new(0.1, 0, 0.34, 0)
- WaitTimeLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
- WaitTimeLabel.Parent = MobileGui
- local WaitTimeTextBox = Instance.new("TextBox")
- WaitTimeTextBox.Text = tostring(waitTimeIfNoMobs)
- WaitTimeTextBox.Position = UDim2.new(0.3, 0, 0.34, 0)
- WaitTimeTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
- WaitTimeTextBox.Parent = MobileGui
- WaitTimeTextBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local newWaitTime = tonumber(WaitTimeTextBox.Text)
- if newWaitTime then
- waitTimeIfNoMobs = newWaitTime
- saveSettings()
- end
- end
- end)
- -- Coin Stay Duration setting
- local CoinDurationLabel = Instance.new("TextLabel")
- CoinDurationLabel.Text = "Coin Stay Duration:"
- CoinDurationLabel.Position = UDim2.new(0.1, 0, 0.4, 0)
- CoinDurationLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
- CoinDurationLabel.Parent = MobileGui
- local CoinDurationTextBox = Instance.new("TextBox")
- CoinDurationTextBox.Text = tostring(coinStayDuration)
- CoinDurationTextBox.Position = UDim2.new(0.3, 0, 0.4, 0)
- CoinDurationTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
- CoinDurationTextBox.Parent = MobileGui
- CoinDurationTextBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local newDuration = tonumber(CoinDurationTextBox.Text)
- if newDuration then
- coinStayDuration = newDuration
- saveSettings()
- end
- end
- end)
- -- Mob Range setting
- local MobRangeLabel = Instance.new("TextLabel")
- MobRangeLabel.Text = "Mob Range:"
- MobRangeLabel.Position = UDim2.new(0.1, 0, 0.46, 0)
- MobRangeLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
- MobRangeLabel.Parent = MobileGui
- local MobRangeTextBox = Instance.new("TextBox")
- MobRangeTextBox.Text = tostring(mobRange)
- MobRangeTextBox.Position = UDim2.new(0.3, 0, 0.46, 0)
- MobRangeTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
- MobRangeTextBox.Parent = MobileGui
- MobRangeTextBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local newRange = tonumber(MobRangeTextBox.Text)
- if newRange then
- mobRange = newRange
- saveSettings()
- end
- end
- end)
- --KeyPress Cooldown Setting
- local KeyPressCooldownLabel = Instance.new("TextLabel")
- KeyPressCooldownLabel.Text = "Keypress Cooldown:"
- KeyPressCooldownLabel.Position = UDim2.new(0.1, 0, 0.52, 0)
- KeyPressCooldownLabel.Size = UDim2.new(0.2, 0, 0.05, 0)
- KeyPressCooldownLabel.Parent = MobileGui
- local KeyPressCooldownTextBox = Instance.new("TextBox")
- KeyPressCooldownTextBox.Text = tostring(keyPressCooldown)
- KeyPressCooldownTextBox.Position = UDim2.new(0.3, 0, 0.52, 0)
- KeyPressCooldownTextBox.Size = UDim2.new(0.2, 0, 0.05, 0)
- KeyPressCooldownTextBox.Parent = MobileGui
- KeyPressCooldownTextBox.FocusLost:Connect(function(enterPressed)
- if enterPressed then
- local newCooldown = tonumber(KeyPressCooldownTextBox.Text)
- if newCooldown then
- keyPressCooldown = newCooldown
- saveSettings()
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement