TKFP

Untitled

Mar 12th, 2025 (edited)
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local LocalPlayer = Players.LocalPlayer
  3. local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
  4. local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
  5. local enabled = false -- Status serangan
  6. local detectNPCs = true -- Status deteksi NPC
  7. local attackRadius = 30 -- Jarak serangan dalam stud
  8. local auraObjects = {} -- Menyimpan aura NPC
  9.  
  10. -- Fungsi untuk membuat efek aura (Highlight)
  11. local function createAura(npc)
  12. if not npc:FindFirstChild("HumanoidRootPart") then return end
  13.  
  14. local aura = Instance.new("Highlight")
  15. aura.FillColor = Color3.fromRGB(255, 0, 0) -- Warna merah
  16. aura.FillTransparency = 0.5 -- Cahaya sedikit transparan
  17. aura.OutlineColor = Color3.fromRGB(255, 255, 255) -- Outline putih
  18. aura.OutlineTransparency = 0 -- Outline terlihat jelas
  19. aura.Parent = npc
  20. aura.Name = "NPC_Aura"
  21.  
  22. -- Simpan aura agar bisa dihapus nanti
  23. auraObjects[npc] = aura
  24. end
  25.  
  26. -- Fungsi untuk menghapus semua aura NPC
  27. local function removeAuras()
  28. for npc, aura in pairs(auraObjects) do
  29. if aura then
  30. aura:Destroy()
  31. end
  32. end
  33. auraObjects = {} -- Reset daftar aura
  34. end
  35.  
  36. -- Fungsi untuk mendeteksi NPC dan memberi aura
  37. local function detectAndMarkNPCs()
  38. if not detectNPCs then
  39. removeAuras()
  40. return
  41. end
  42.  
  43. for _, npc in pairs(workspace:GetChildren()) do
  44. if npc:IsA("Model") and npc:FindFirstChild("Humanoid") and npc:FindFirstChild("HumanoidRootPart") then
  45. if not Players:GetPlayerFromCharacter(npc) and not auraObjects[npc] then
  46. createAura(npc)
  47. end
  48. end
  49. end
  50. end
  51.  
  52. -- Fungsi untuk menyerang NPC dalam radius tertentu
  53. local function attackNPCs()
  54. while enabled do
  55. if detectNPCs then -- Hanya serang jika deteksi aktif
  56. for _, npc in pairs(workspace:GetChildren()) do
  57. if npc:IsA("Model") and npc:FindFirstChild("Humanoid") and npc:FindFirstChild("HumanoidRootPart") then
  58. if not Players:GetPlayerFromCharacter(npc) and npc ~= Character then
  59. local distance = (HumanoidRootPart.Position - npc.HumanoidRootPart.Position).magnitude
  60. if distance <= attackRadius then
  61. local humanoid = npc:FindFirstChild("Humanoid")
  62. if humanoid then
  63. humanoid.Health = humanoid.Health - 50
  64. if humanoid.Health <= 0 then
  65. npc:Destroy()
  66. end
  67. end
  68. end
  69. end
  70. end
  71. end
  72. end
  73. task.wait(0.2) -- Jeda serangan
  74. end
  75. end
  76.  
  77. -- GUI
  78. local ScreenGui = Instance.new("ScreenGui")
  79. ScreenGui.Parent = LocalPlayer:FindFirstChildOfClass("PlayerGui")
  80.  
  81. -- Tombol untuk mengaktifkan/menonaktifkan serangan NPC
  82. local AttackButton = Instance.new("TextButton", ScreenGui)
  83. AttackButton.Size = UDim2.new(0, 200, 0, 50)
  84. AttackButton.Position = UDim2.new(0.05, 0, 0.1, 0)
  85. AttackButton.Text = "Mulai Serang NPC"
  86. AttackButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  87.  
  88. AttackButton.MouseButton1Click:Connect(function()
  89. enabled = not enabled
  90. if enabled then
  91. AttackButton.Text = "Hentikan Serangan"
  92. AttackButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  93. attackNPCs()
  94. else
  95. AttackButton.Text = "Mulai Serang NPC"
  96. AttackButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  97. end
  98. end)
  99.  
  100. -- Tombol untuk menyalakan/mematikan deteksi NPC
  101. local DetectButton = Instance.new("TextButton", ScreenGui)
  102. DetectButton.Size = UDim2.new(0, 200, 0, 50)
  103. DetectButton.Position = UDim2.new(0.05, 0, 0.2, 0)
  104. DetectButton.Text = "Deteksi NPC: ON"
  105. DetectButton.BackgroundColor3 = Color3.fromRGB(0, 255, 255)
  106.  
  107. DetectButton.MouseButton1Click:Connect(function()
  108. detectNPCs = not detectNPCs
  109. if detectNPCs then
  110. DetectButton.Text = "Deteksi NPC: ON"
  111. DetectButton.BackgroundColor3 = Color3.fromRGB(0, 255, 255)
  112. detectAndMarkNPCs()
  113. else
  114. DetectButton.Text = "Deteksi NPC: OFF"
  115. DetectButton.BackgroundColor3 = Color3.fromRGB(255, 165, 0)
  116. removeAuras()
  117. end
  118. end)
  119.  
  120. -- Update terus deteksi NPC setiap 0.5 detik
  121. task.spawn(function()
  122. while true do
  123. if detectNPCs then
  124. detectAndMarkNPCs()
  125. end
  126. task.wait(0.5)
  127. end
  128. end)
Advertisement
Add Comment
Please, Sign In to add comment