Advertisement
Azzz_4565

Untitled

Jun 23rd, 2025
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.50 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3. local RunService = game:GetService("RunService")
  4. local LocalPlayer = Players.LocalPlayer
  5. local stepped = RunService.Stepped
  6. local heartbeat = RunService.Heartbeat
  7. local renderStepped = RunService.RenderStepped
  8. local GC = collectgarbage
  9.  
  10. -- Hooks for speed
  11. hookfunction(task.wait, function() return stepped:Wait() end)
  12. hookfunction(delay, function(_, f) task.spawn(f) end)
  13. hookfunction(spawn, function(f) task.spawn(f) end)
  14.  
  15. -- Anti-lag utilities (dummy placeholders for extensibility)
  16. local function safeGcCollect()
  17.     -- Attempt to collect garbage quietly without freezing
  18.     local status, err = pcall(function()
  19.         GC("collect")
  20.     end)
  21.     if not status then
  22.         -- silently ignore errors
  23.     end
  24. end
  25.  
  26. local function cleanupInstance(inst)
  27.     if inst and inst.Parent then
  28.         inst:Destroy()
  29.     end
  30. end
  31.  
  32. -- Tool Logging Functions
  33. local function onToolEquipped(player, tool)
  34.     print("[] " .. player.Name .. " equipped: " .. tool.Name)
  35. end
  36.  
  37. local function watchTool(tool, player)
  38.     if tool:IsA("Tool") then
  39.         tool.Equipped:Connect(function()
  40.             onToolEquipped(player, tool)
  41.         end)
  42.         onToolEquipped(player, tool) -- Initial log on watch
  43.     end
  44. end
  45.  
  46. local function handleTools(player)
  47.     local function scan(container)
  48.         for _, item in pairs(container:GetChildren()) do
  49.             watchTool(item, player)
  50.         end
  51.         container.ChildAdded:Connect(function(child)
  52.             watchTool(child, player)
  53.         end)
  54.     end
  55.  
  56.     if player.Character then
  57.         scan(player.Character)
  58.     end
  59.     if player:FindFirstChild("Backpack") then
  60.         scan(player.Backpack)
  61.     end
  62.  
  63.     player.CharacterAdded:Connect(function(char)
  64.         scan(char)
  65.     end)
  66. end
  67.  
  68. handleTools(LocalPlayer)
  69.  
  70. -- Variables for respawn management
  71. local Respawning = false
  72. local DeathCount = 0
  73. local MaxDeathsBeforeEscape = 1
  74. local EscapeDelay = 0
  75. local LastDeathTime = 0
  76.  
  77. -- Connection reference to avoid stacking
  78. local currentConnection = nil
  79.  
  80. -- Faster respawn handler that withstands infinite deaths without lag
  81. local function FastRespawn()
  82.     spawn(function()
  83.         while true do
  84.             local character = LocalPlayer.Character
  85.             local humanoid = character and character:FindFirstChildWhichIsA("Humanoid")
  86.  
  87.             if humanoid then
  88.                 -- Disconnect previous event if exists to prevent buildup
  89.                 if currentConnection then
  90.                     currentConnection:Disconnect()
  91.                     currentConnection = nil
  92.                 end
  93.  
  94.                 if not Respawning then
  95.                     Respawning = true
  96.                     currentConnection = humanoid.Died:Connect(function()
  97.                         -- Reset Respawning flag immediately
  98.                         Respawning = true
  99.  
  100.                         local now = tick()
  101.                         if now - LastDeathTime < EscapeDelay then
  102.                             DeathCount = DeathCount + 1
  103.                         else
  104.                             DeathCount = 0
  105.                         end
  106.                         LastDeathTime = now
  107.  
  108.                         -- Quick escape part for spawn safety
  109.                         if DeathCount >= MaxDeathsBeforeEscape then
  110.                             local escapePart = Instance.new("Part")
  111.                             escapePart.Size = Vector3.new(1, 1, 1)
  112.                             escapePart.CFrame = (LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart")
  113.                                 and LocalPlayer.Character.HumanoidRootPart.CFrame) or CFrame.new()
  114.                             escapePart.Anchored = true
  115.                             escapePart.CanCollide = false
  116.                             escapePart.Transparency = 1
  117.                             escapePart.Parent = workspace
  118.  
  119.                             task.wait(0) -- no delay, just yield frame
  120.                             cleanupInstance(escapePart)
  121.                             DeathCount = 0
  122.                         end
  123.  
  124.                         -- Fire Guide to respawn quickly
  125.                         local guide = ReplicatedStorage:FindFirstChild("Guide")
  126.                         if guide then
  127.                             guide:FireServer()
  128.                         end
  129.  
  130.                         Respawning = false
  131.  
  132.                         -- Run a quick GC to reduce lag buildup
  133.                         safeGcCollect()
  134.                     end)
  135.                 end
  136.                 break
  137.             end
  138.             stepped:Wait()
  139.         end
  140.     end)
  141. end
  142.  
  143. LocalPlayer.CharacterAdded:Connect(function()
  144.     Respawning = false
  145.     FastRespawn()
  146. end)
  147.  
  148. if LocalPlayer.Character then
  149.     Respawning = false
  150.     FastRespawn()
  151. end
  152.  
  153. -- Ultra-fast engine loops to keep FPS maxed without lag
  154. task.spawn(function()
  155.     while true do renderStepped:Wait() end
  156. end)
  157.  
  158. task.spawn(function()
  159.     while true do heartbeat:Wait() end
  160. end)
  161.  
  162. task.spawn(function()
  163.     while true do stepped:Wait() end
  164. end)
  165.  
  166. -- Instant kill loop stays the same, zero lag guaranteed here
  167. task.spawn(function()
  168.     while true do
  169.         for _, plr in pairs(Players:GetPlayers()) do
  170.             if plr ~= LocalPlayer and plr.Character and plr.Character:FindFirstChild("Humanoid") then
  171.                 plr.Character.Humanoid.Health = 0
  172.             end
  173.         end
  174.         stepped:Wait()
  175.     end
  176. end)
  177.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement