RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create a script that destroys a part when a player kills a certain amount of NPCs"
-- server script local part = game.Workspace.PartToDestroy local requiredKills = 5 game.Players.PlayerAdded:Connect(function(player) local kills = Instance.new("IntValue") kills.Name = "NPCkills" kills.Value = 0 kills.Parent = player player.NPCkills.Changed:Connect(function() if player.NPCkills.Value >= requiredKills then part:Destroy() end end) end) -- script for NPC death local npc = script.Parent local humanoid = npc:WaitForChild("Humanoid") humanoid.Died:Connect(function() local killer = humanoid:GetKiller() if killer then local player = game.Players:GetPlayerFromCharacter(killer.Parent) if player then player.NPCkills.Value = player.NPCkills.Value + 1 end end end)