Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
- local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
- local enabled = false -- Status serangan
- local detectNPCs = true -- Status deteksi NPC
- local attackRadius = 30 -- Jarak serangan dalam stud
- local auraObjects = {} -- Menyimpan aura NPC
- -- Fungsi untuk membuat efek aura (Highlight)
- local function createAura(npc)
- if not npc:FindFirstChild("HumanoidRootPart") then return end
- local aura = Instance.new("Highlight")
- aura.FillColor = Color3.fromRGB(255, 0, 0) -- Warna merah
- aura.FillTransparency = 0.5 -- Cahaya sedikit transparan
- aura.OutlineColor = Color3.fromRGB(255, 255, 255) -- Outline putih
- aura.OutlineTransparency = 0 -- Outline terlihat jelas
- aura.Parent = npc
- aura.Name = "NPC_Aura"
- -- Simpan aura agar bisa dihapus nanti
- auraObjects[npc] = aura
- end
- -- Fungsi untuk menghapus semua aura NPC
- local function removeAuras()
- for npc, aura in pairs(auraObjects) do
- if aura then
- aura:Destroy()
- end
- end
- auraObjects = {} -- Reset daftar aura
- end
- -- Fungsi untuk mendeteksi NPC dan memberi aura
- local function detectAndMarkNPCs()
- if not detectNPCs then
- removeAuras()
- return
- end
- for _, npc in pairs(workspace:GetChildren()) do
- if npc:IsA("Model") and npc:FindFirstChild("Humanoid") and npc:FindFirstChild("HumanoidRootPart") then
- if not Players:GetPlayerFromCharacter(npc) and not auraObjects[npc] then
- createAura(npc)
- end
- end
- end
- end
- -- Fungsi untuk menyerang NPC dalam radius tertentu
- local function attackNPCs()
- while enabled do
- if detectNPCs then -- Hanya serang jika deteksi aktif
- for _, npc in pairs(workspace:GetChildren()) do
- if npc:IsA("Model") and npc:FindFirstChild("Humanoid") and npc:FindFirstChild("HumanoidRootPart") then
- if not Players:GetPlayerFromCharacter(npc) and npc ~= Character then
- local distance = (HumanoidRootPart.Position - npc.HumanoidRootPart.Position).magnitude
- if distance <= attackRadius then
- local humanoid = npc:FindFirstChild("Humanoid")
- if humanoid then
- humanoid.Health = humanoid.Health - 50
- if humanoid.Health <= 0 then
- npc:Destroy()
- end
- end
- end
- end
- end
- end
- end
- task.wait(0.2) -- Jeda serangan
- end
- end
- -- GUI
- local ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Parent = LocalPlayer:FindFirstChildOfClass("PlayerGui")
- -- Tombol untuk mengaktifkan/menonaktifkan serangan NPC
- local AttackButton = Instance.new("TextButton", ScreenGui)
- AttackButton.Size = UDim2.new(0, 200, 0, 50)
- AttackButton.Position = UDim2.new(0.05, 0, 0.1, 0)
- AttackButton.Text = "Mulai Serang NPC"
- AttackButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- AttackButton.MouseButton1Click:Connect(function()
- enabled = not enabled
- if enabled then
- AttackButton.Text = "Hentikan Serangan"
- AttackButton.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- attackNPCs()
- else
- AttackButton.Text = "Mulai Serang NPC"
- AttackButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- end
- end)
- -- Tombol untuk menyalakan/mematikan deteksi NPC
- local DetectButton = Instance.new("TextButton", ScreenGui)
- DetectButton.Size = UDim2.new(0, 200, 0, 50)
- DetectButton.Position = UDim2.new(0.05, 0, 0.2, 0)
- DetectButton.Text = "Deteksi NPC: ON"
- DetectButton.BackgroundColor3 = Color3.fromRGB(0, 255, 255)
- DetectButton.MouseButton1Click:Connect(function()
- detectNPCs = not detectNPCs
- if detectNPCs then
- DetectButton.Text = "Deteksi NPC: ON"
- DetectButton.BackgroundColor3 = Color3.fromRGB(0, 255, 255)
- detectAndMarkNPCs()
- else
- DetectButton.Text = "Deteksi NPC: OFF"
- DetectButton.BackgroundColor3 = Color3.fromRGB(255, 165, 0)
- removeAuras()
- end
- end)
- -- Update terus deteksi NPC setiap 0.5 detik
- task.spawn(function()
- while true do
- if detectNPCs then
- detectAndMarkNPCs()
- end
- task.wait(0.5)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment