Laser gun for NPCs | by DuaKNo
Key RequiredUniversal

Laser gun for NPCs | by DuaKNo

Universal ScriptDuaKNoDuaKNo 1.3K views 6.5K executesUpdated Sep 29, 2026
Unrated
00
Lua Script•568 lines (16521 chars)
local StarterGui      = game:GetService("StarterGui")
local Players         = game:GetService("Players")
local ContentProvider = game:GetService("ContentProvider")

local ROBLOX_USERNAME   = "DuaKNo"
local INSTAGRAM_HANDLE  = "me_duakno"

local OWNER_USER_ID = 0
pcall(function()
	OWNER_USER_ID = Players:GetUserIdFromNameAsync(ROBLOX_USERNAME)
end)

local AVATAR_ICON = ("rbxthumb://type=AvatarHeadShot&id=%d&w=420&h=420"):format(OWNER_USER_ID)

pcall(function()
	ContentProvider:PreloadAsync({ AVATAR_ICON })
end)

local function sendNotif(title, text, duration)
	pcall(function()
		StarterGui:SetCore("SendNotification", {
			Title    = title,
			Text     = text,
			Icon     = AVATAR_ICON,
			Duration = duration or 5,
		})
	end)
end

task.spawn(function()
	sendNotif("Kill Laser gun for NPC", "by DuaKNo", 5)
	task.wait(2)
	sendNotif("Follow on Instagram", INSTAGRAM_HANDLE, 5)
end)

local LocalPlayer = game:GetService("Players").LocalPlayer

local function boostRadius()
	pcall(function() sethiddenproperty(LocalPlayer, "SimulationRadius", 5000) end)
	pcall(function() setsimulationradius(5000, 5000) end)
end

boostRadius()

task.spawn(function()
	while true do
		task.wait(2)
		boostRadius()
	end
end)

local function runDummyScript(f, scri)
	local oldenv = getfenv(f)
	local newenv = setmetatable({}, {
		__index = function(_, k)
			if k:lower() == 'script' then return scri else return oldenv[k] end
		end
	})
	setfenv(f, newenv)
	ypcall(function() f() end)
end

local cors = {}

local mas = Instance.new("Model", game:GetService("Lighting"))
mas.Name = "CompiledModel"

local Tool          = Instance.new("Tool")
local Handle        = Instance.new("Part")
local Mesh          = Instance.new("SpecialMesh")
local FireSound     = Instance.new("Sound")
local ReloadSound   = Instance.new("Sound")
local PointLight    = Instance.new("PointLight")
local ToolScript    = Instance.new("LocalScript")
local HitFadeSound  = Instance.new("Sound")
local MouseIcon     = Instance.new("LocalScript")
local ShuHold       = Instance.new("Script")

Tool.Name = "KILL LASER GUN\n(NPCs ONLY)"
Tool.Parent = mas
Tool.TextureId = ""
Tool.GripPos = Vector3.new(0, -0.100000001, 0.75)
Tool.CanBeDropped = false

Handle.Name = "Handle"
Handle.Parent = Tool
Handle.Position = Vector3.new(6.44000006, 0.670018971, 89.4400024)
Handle.Rotation = Vector3.new(-180, 0, -180)
Handle.CanCollide = false
Handle.FormFactor = Enum.FormFactor.Custom
Handle.Size = Vector3.new(0.580000222, 1.34000099, 2.48000145)
Handle.CFrame = CFrame.new(6.44000006, 0.670018971, 89.4400024, -1, 0, 0, 0, 1, 0, 0, 0, -1)
Handle.BottomSurface = Enum.SurfaceType.Smooth
Handle.TopSurface = Enum.SurfaceType.Smooth

Mesh.Parent = Handle
Mesh.MeshId = "http://www.roblox.com/asset?id=130099641"
Mesh.Scale = Vector3.new(0.649999976, 0.649999976, 0.649999976)
Mesh.TextureId = "http://www.roblox.com/asset/?id=130267361"
Mesh.MeshType = Enum.MeshType.FileMesh

FireSound.Name = "Fire"
FireSound.Parent = Handle
FireSound.Pitch = 1.2000000476837
FireSound.SoundId = "http://www.roblox.com/asset?id=114488148"
FireSound.Volume = 1

ReloadSound.Name = "Reload"
ReloadSound.Parent = Handle
ReloadSound.Pitch = 0.5
ReloadSound.SoundId = "http://www.roblox.com/asset?id=94255248"

PointLight.Parent = Handle
PointLight.Color = Color3.new(1, 0, 0)
PointLight.Brightness = 50
PointLight.Range = 10

ToolScript.Name = "ToolScript"
ToolScript.Parent = Tool
table.insert(cors, coroutine.create(function()
	wait()
	runDummyScript(function()
		local SHOT_SPEED = 350
		local SHOT_TIME  = 20000
		local NOZZLE_OFFSET = Vector3.new(0, 0.4, -1.1)

		local PlayersService = Game:GetService('Players')
		local DebrisService  = Game:GetService('Debris')

		local Tool = script.Parent
		local Handle = Tool:WaitForChild('Handle')
		local FireSound = Handle:WaitForChild('Fire')
		local ReloadSound = Handle:WaitForChild('Reload')
		local HitFadeSound = script:WaitForChild('HitFade')
		local PointLight = Handle:WaitForChild('PointLight')

		local Character, Humanoid, Player = nil, nil, nil
		local BaseShot = nil

		local function FindCharacterAncestor(subject)
			if subject and subject ~= Workspace then
				local humanoid = subject:FindFirstChild('Humanoid')
				if humanoid then
					return subject, humanoid
				else
					return FindCharacterAncestor(subject.Parent)
				end
			end
			return nil
		end

		local function ApplyTags(target)
			while target:FindFirstChild('creator') do
				target.creator:Destroy()
			end
			local creatorTag = Instance.new('ObjectValue')
			creatorTag.Value = Player
			creatorTag.Name = 'creator'
			local iconTag = Instance.new('StringValue')
			iconTag.Value = Tool.TextureId
			iconTag.Name = 'icon'
			iconTag.Parent = creatorTag
			creatorTag.Parent = target
			DebrisService:AddItem(creatorTag, 4)
		end

		local function GetTransparentsRecursive(instance, partsTable)
			local partsTable = partsTable or {}
			for _, child in pairs(instance:GetChildren()) do
				if child:IsA('BasePart') or child:IsA('Decal') then
					table.insert(partsTable, child)
				end
				GetTransparentsRecursive(child, partsTable)
			end
			return partsTable
		end

		local function SelectionBoxify(instance)
			local selectionBox = Instance.new('SelectionBox')
			selectionBox.Adornee = instance
			selectionBox.Color = BrickColor.new('Really red')
			selectionBox.Parent = instance
			return selectionBox
		end

		local function Light(instance)
			local light = PointLight:Clone()
			light.Range = light.Range + 2
			light.Parent = instance
		end

		local function FadeOutObjects(objectsWithTransparency, fadeIncrement)
			repeat
				local lastObject = nil
				for _, object in pairs(objectsWithTransparency) do
					object.Transparency = object.Transparency + fadeIncrement
					lastObject = object
				end
				wait()
			until lastObject.Transparency >= 1 or not lastObject
		end

		local function ApplyDamageStack(humanoid)
			if not humanoid or not humanoid.Parent then return end
			pcall(function() humanoid.Health = -1 end)
			pcall(function() humanoid:ChangeState(Enum.HumanoidStateType.Dead) end)
			pcall(function() humanoid:TakeDamage(9999999999) end)
		end

		local function PushNPC(character, direction)
			if not character or not direction then return end
			if direction.Magnitude < 0.01 then return end
			local root = character:FindFirstChild("HumanoidRootPart") or character.PrimaryPart
			if not root then return end
			local bv = Instance.new("BodyVelocity")
			bv.MaxForce = Vector3.new(1e6, 1e6, 1e6)
			bv.Velocity = (direction.Unit * 30) + Vector3.new(0, 10, 0)
			bv.Parent = root
			DebrisService:AddItem(bv, 0.4)
		end

		local function WeOwnCharacter(character)
			local root = character:FindFirstChild("HumanoidRootPart") or character.PrimaryPart
			if not root then return false end
			local owner = nil
			pcall(function() owner = root:GetNetworkOwner() end)
			return owner == PlayersService.LocalPlayer
		end

		local function TryTakeOwnership(character)
			if not character or not character.Parent then return false end
			local gotAny = false
			for _, part in pairs(character:GetChildren()) do
				if part:IsA("BasePart") then
					local ok = pcall(function()
						part:SetNetworkOwner(PlayersService.LocalPlayer)
					end)
					if ok then gotAny = true end
				end
			end
			for _, part in pairs(character:GetDescendants()) do
				if part:IsA("BasePart") then
					pcall(function() part:SetNetworkOwner(PlayersService.LocalPlayer) end)
				end
			end
			return gotAny
		end

		local function Dematerialize(character, humanoid, firstPart, pushDir)
			ApplyDamageStack(humanoid)

			PushNPC(character, pushDir)
			wait(0.15)

			pcall(function() humanoid.WalkSpeed = 0 end)

			local parts = {}
			for _, child in pairs(character:GetChildren()) do
				if child:IsA('BasePart') then
					child.Anchored = true
					table.insert(parts, child)
				elseif child:IsA('LocalScript') or child:IsA('Script') then
					child:Destroy()
				end
			end

			local selectionBoxes = {}
			local firstSelectionBox = SelectionBoxify(firstPart)
			Light(firstPart)
			wait(0.05)

			for _, part in pairs(parts) do
				if part ~= firstPart then
					table.insert(selectionBoxes, SelectionBoxify(part))
					Light(part)
				end
			end

			local objectsWithTransparency = GetTransparentsRecursive(character)
			FadeOutObjects(objectsWithTransparency, 0.1)
			wait(0.5)

			ApplyDamageStack(humanoid)
			DebrisService:AddItem(character, 2)

			local fadeIncrement = 0.05
			Delay(0.2, function()
				FadeOutObjects({firstSelectionBox}, fadeIncrement)
				if character then
					character:Destroy()
				end
			end)
			FadeOutObjects(selectionBoxes, fadeIncrement)
		end

		local function HitFlash(part)
			if not part or not part.Parent then return end
			local light = PointLight:Clone()
			light.Range = 6
			light.Brightness = 20
			light.Parent = part
			Delay(0.3, function()
				if light and light.Parent then light:Destroy() end
			end)
		end

		local function ReliableKill(character, humanoid, otherPart, pushDir)
			HitFlash(otherPart)
			local pushedOnce = false

			task.spawn(function()
				for i = 1, 60 do
					if not character.Parent or not humanoid.Parent then return end

					if WeOwnCharacter(character) then
						Dematerialize(character, humanoid, otherPart, pushDir)
						return
					end

					TryTakeOwnership(character)

					if WeOwnCharacter(character) then
						Dematerialize(character, humanoid, otherPart, pushDir)
						return
					end

					ApplyDamageStack(humanoid)

					if not pushedOnce then
						PushNPC(character, pushDir)
						pushedOnce = true
					end

					wait(0.1)
				end

				if character.Parent and humanoid.Parent and WeOwnCharacter(character) then
					Dematerialize(character, humanoid, otherPart, pushDir)
				end
			end)
		end

		local function OnTouched(shot, otherPart)
			if not shot or not shot.Parent then return end
			if shot:GetAttribute("HitNPC") then return end

			local character, humanoid = FindCharacterAncestor(otherPart)
			if not (character and humanoid) then return end
			if character == Character then return end

			if PlayersService:GetPlayerFromCharacter(character) then return end

			shot:SetAttribute("HitNPC", true)

			local pushDir = shot.CFrame.LookVector
			local bv = shot:FindFirstChildOfClass("BodyVelocity")
			if bv then pushDir = bv.Velocity end

			ApplyTags(humanoid)

			local hitFadeSound = shot:FindFirstChild(HitFadeSound.Name)
			if hitFadeSound then
				local torso = humanoid:FindFirstChild("Torso")
					or humanoid:FindFirstChild("UpperTorso")
					or character:FindFirstChild("HumanoidRootPart")
				if torso then
					hitFadeSound.Parent = torso
					hitFadeSound:Play()
				end
			end

			shot:Destroy()

			if WeOwnCharacter(character) then
				Dematerialize(character, humanoid, otherPart, pushDir)
			else
				TryTakeOwnership(character)

				if WeOwnCharacter(character) then
					Dematerialize(character, humanoid, otherPart, pushDir)
				else
					ReliableKill(character, humanoid, otherPart, pushDir)
				end
			end
		end

		local function OnEquipped()
			Character = Tool.Parent
			Humanoid = Character:WaitForChild('Humanoid')
			Player = PlayersService:GetPlayerFromCharacter(Character)
		end

		local function OnActivated()
			if Tool.Enabled and Humanoid.Health > 0 then
				Tool.Enabled = false
				FireSound:Play()

				local handleCFrame = Handle.CFrame
				local firingPoint = handleCFrame.p + handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET)
				local shotCFrame = CFrame.new(firingPoint, Humanoid.TargetPoint)

				local laserShotClone = BaseShot:Clone()
				laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector * (BaseShot.Size.Z / 2))
				local bodyVelocity = Instance.new('BodyVelocity')
				bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED
				bodyVelocity.Parent = laserShotClone
				laserShotClone.Touched:connect(function(otherPart)
					OnTouched(laserShotClone, otherPart)
				end)
				DebrisService:AddItem(laserShotClone, SHOT_TIME)
				laserShotClone.Parent = Tool

				wait(0)
				ReloadSound:Play()
				wait(0)
				Tool.Enabled = true
			end
		end

		local function OnUnequipped() end

		BaseShot = Instance.new('Part')
		BaseShot.Name = 'Effect'
		BaseShot.FormFactor = Enum.FormFactor.Custom
		BaseShot.Size = Vector3.new(0.2, 0.2, 3)
		BaseShot.CanCollide = false
		BaseShot.BrickColor = BrickColor.new('Really red')
		SelectionBoxify(BaseShot)
		Light(BaseShot)
		HitFadeSound:Clone().Parent = BaseShot

		Tool.Equipped:connect(OnEquipped)
		Tool.Unequipped:connect(OnUnequipped)
		Tool.Activated:connect(OnActivated)
	end, ToolScript)
end))

HitFadeSound.Name = "HitFade"
HitFadeSound.Parent = ToolScript
HitFadeSound.SoundId = "http://www.roblox.com/asset?id=130113415"

MouseIcon.Name = "MouseIcon"
MouseIcon.Parent = Tool
table.insert(cors, coroutine.create(function()
	wait()
	runDummyScript(function()
		local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
		local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'
		local Tool = script.Parent
		local Mouse = nil
		local function UpdateIcon()
			if Mouse then Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON end
		end
		local function OnEquipped(mouse) Mouse = mouse; UpdateIcon() end
		local function OnChanged(property) if property == 'Enabled' then UpdateIcon() end end
		Tool.Equipped:connect(OnEquipped)
		Tool.Changed:connect(OnChanged)
	end, MouseIcon)
end))

ShuHold.Name = "Shu_hold"
ShuHold.Parent = Tool
table.insert(cors, coroutine.create(function()
	wait()
	runDummyScript(function()
		selected = false
		RSH, LSH = nil, nil
		GRP = nil
		RW, LW = Instance.new("Weld"), Instance.new("Weld")
		anim = "none"

		function WaitForChild(obj, ch_n)
			local t = time()
			while not obj:FindFirstChild(ch_n) and time() - t < 10 do wait(0.1) end
			return obj:FindFirstChild(ch_n)
		end

		script.Parent.Equipped:connect(function()
			if selected then return end
			selected = true
			player = game.Players:playerFromCharacter(script.Parent.Parent)
			local ch = script.Parent.Parent
			WaitForChild(ch, "Torso")
			RSH = WaitForChild(ch.Torso, "Right Shoulder")
			LSH = WaitForChild(ch.Torso, "Left Shoulder")
			GRP = WaitForChild(ch["Right Arm"], "RightGrip")
			_G.Grip = GRP
			RSH.Part1 = nil
			LSH.Part1 = nil
			RW.Part0 = ch.Torso
			RW.C0 = CFrame.new(1.5, 0.5, 0)
			RW.C1 = CFrame.new(0, 0.5, 0)
			RW.Part1 = ch["Right Arm"]
			RW.Parent = ch.Torso
			_G.R = RW
			LW.Part0 = ch.Torso
			LW.C0 = CFrame.new(-1.5, 0.5, 0)
			LW.C1 = CFrame.new(0, 0.5, 0)
			LW.Part1 = ch["Left Arm"]
			LW.Parent = ch.Torso
			_G.L = LW
			GRP.C0 = CFrame.new(0, -1, -0.5) * CFrame.fromEulerAnglesXYZ(-1.22, -0.45, 0.22)
			for i = 0, 1, 0.05 do
				wait()
				RW.C0 = CFrame.new(1.5, 0.5, 0.25) * CFrame.fromEulerAnglesXYZ(1.3*i, 0, -0.5*i)
				LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7*i, 0, 0.8*i)
				LW.C1 = CFrame.new(0.3*i, 1+1*i, 0)
			end
			wait()
			local rg = (ch["Right Arm"]:FindFirstChild("RightGrip") or GRP)
			if rg ~= GRP then
				GRP.Parent = ch["Right Arm"]
				rg:remove()
			end
		end)

		script.Parent.Unequipped:connect(function()
			selected = false
			local pl = player
			RW.C0 = CFrame.new(0,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
			LW.C0 = CFrame.new(0,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
			LW.C1 = CFrame.new(0,0,0)
			RW.Parent = nil
			LW.Parent = nil
			RSH.Part1 = pl.Character["Right Arm"]
			LSH.Part1 = pl.Character["Left Arm"]
		end)

		function armReload()
			for i = 0, 1, 0.1 do
				wait()
				LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.3*i, 0, 0.9*i)
				LW.C1 = CFrame.new(0.3*i, 1+1*i, 0)
			end
		end

		function gunOut()
			for i = 0, 0.3, 0.06 do
				wait()
				GRP.C0 = CFrame.new(0+i, -1-i, 0+(2*i)) * CFrame.fromEulerAnglesXYZ(-2.22, -0.45, 0.42)
				LW.C0 = CFrame.new(-1, 0.5, 0) * CFrame.fromEulerAnglesXYZ(4.2, 0, 2.9)
				LW.C1 = CFrame.new(0.8*i, 1.1+i, -0.3)
			end
		end

		function gunReturn()
			RW.C0 = CFrame.new(1.5, 0.5, 0.25) * CFrame.fromEulerAnglesXYZ(1.3, 0, -0.5)
			LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8)
			LW.C1 = CFrame.new(0.3, 1+1, 0)
			GRP.C0 = CFrame.new(0, -1, -0.5) * CFrame.fromEulerAnglesXYZ(-1.22, -0.45, 0.22)
		end
	end, ShuHold)
end))

mas.Parent = workspace
mas:MakeJoints()

local masChildren = mas:GetChildren()
for i = 1, #masChildren do
	masChildren[i].Parent = game:GetService("Players").LocalPlayer.Backpack
	ypcall(function() masChildren[i]:MakeJoints() end)
end

mas:Destroy()

for i = 1, #cors do
	coroutine.resume(cors[i])
end

Features & Information

Kill Laser gun for NPCs only It gives you a laser gun that only kills npc You first need to own the npc part with ownership so get my show ownership script from my profile
#Fun#Op#DuaKNo#Npc#Death

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts