Example:

			if game.Players.LocalPlayer.Character:FindFirstChild("Shock") then
				game.Players.LocalPlayer.Character.Shock:Destroy() -- but i want it to keep 1 script but not delete all of them ? How do i do that ?

Why i want this it's because my script spams the player with alot of scripts and i cannot stop that so i want this script to delete all of them if they find it, but keep ONLY 1 script. is that even possible ?

local sp = script.Parent
local turret = sp.Gun
local target = nil
local ready = true
local targettable = {}
local set = require(script.Settings)

game:GetService('RunService').Stepped:connect(function()
	targettable = {}
	for _,plr in pairs(game.Players:GetChildren()) do
		if plr:DistanceFromCharacter(turret.Position) <= set.radius and plr.TeamColor ~= set.allycolor and plr.Character.Humanoid.Health >0 then
			table.insert(targettable,plr)
		else
			target = nil
			targettable = {}
		end
	end
	if table.getn(targettable)>0 then
		target = targettable[math.random(1,#targettable)]
	elseif table.getn(targettable) == 0 then
		target = nil
	end
	if target ~= nil then
		if ready == true then
			ready = false
			Laser(turret.Position,target.Character.Torso.Position)
			target.Character.Humanoid:TakeDamage(set.damage)
			target.Character:findFirstChild("Head").Reflectance =(math.random(1))
			target.Character:findFirstChild("Torso").Reflectance =(math.random(1))
			target.Character:findFirstChild("Right Arm").Reflectance =(math.random(1))
			target.Character:findFirstChild("Right Leg").Reflectance =(math.random(1))
			target.Character:findFirstChild("Left Arm").Reflectance =(math.random(1))
			target.Character:findFirstChild("Left Leg").Reflectance =(math.random(1))
			target.Character.Humanoid.WalkSpeed = 10
			script.Shock:Clone().Parent = game.Players.LocalPlayer.Character
			turret.Fire:Play()
			wait(set.shotcooldown)
			ready = true
		end
	end
	target = nil
end)

function Laser(StartPosition,TargetPosition,Hit)
	turret.Material = Enum.Material.Neon
	local ray = Instance.new("Part")
	ray.TopSurface = Enum.SurfaceType.Smooth
	ray.BottomSurface = Enum.SurfaceType.Smooth
	ray.FormFactor = Enum.FormFactor.Custom
	ray.Size = Vector3.new(0.5, 0.2, 0.2)
	ray.CanCollide = false
	ray.Locked = true
	ray.Anchored = true
	ray.Name = "Laser"
	ray.BrickColor = BrickColor.new("Cyan")
	ray.Material = Enum.Material.Neon
	ray.Size = Vector3.new(0.0, 0.5, 0.2)
	local raymesh = Instance.new("SpecialMesh")
	raymesh.Name = "Mesh"
	raymesh.MeshType = Enum.MeshType.Brick
	raymesh.Scale = Vector3.new(0.2, 0.2, 1)
	raymesh.Offset = Vector3.new(0, 0, 0)
	raymesh.VertexColor = Vector3.new(1, 1, 1)
	raymesh.Parent = ray
	local Vec = (TargetPosition - StartPosition)
	local Distance = Vec.magnitude
	local Direction = Vec.unit
	local PX = (StartPosition + (0.25 * Distance) * Direction)
	local PY = (StartPosition + (0.5 * Distance) * Direction)
	local PZ = (StartPosition + (0.75 * Distance) * Direction)
	local DX = (StartPosition - PX).magnitude
	local DY = (PX - PY).magnitude
	local DZ = (PY - PZ).magnitude
	local Limit = 2
	local AX = (PX + Vector3.new(math.random(math.max(-Limit, (-0.21 * DX)), math.min(Limit, (0.21 * DX))),math.random(math.max(-Limit, (-0.21 * DX)),math.min(Limit, (0.21 * DX))), math.random(math.max(-Limit, (-0.21 * DX)), math.min(Limit, (0.21 * DX)))))
	local AY = (PY + Vector3.new(math.random(math.max(-Limit, (-0.21 * DY)), math.min(Limit, (0.21 * DY))),math.random(math.max(-Limit, (-0.21 * DY)),math.min(Limit, (0.21 * DY))), math.random(math.max(-Limit, (-0.21 * DY)), math.min(Limit, (0.21 * DY)))))
	local AZ = (PZ + Vector3.new(math.random(math.max(-Limit, (-0.21 * DZ)), math.min(Limit, (0.21 * DZ))),math.random(math.max(-Limit, (-0.21 * DZ)),math.min(Limit, (0.21 * DZ))), math.random(math.max(-Limit, (-0.21 * DZ)), math.min(Limit, (0.21 * DZ)))))
	local Rays = {
		{Distance = (AX - StartPosition).magnitude, Direction = CFrame.new(StartPosition, AX)},
		{Distance = (AY - AX).magnitude, Direction = CFrame.new(AX, AY)},
		{Distance = (AZ - AY).magnitude, Direction = CFrame.new(AY, AZ)},
		{Distance = (TargetPosition - AZ).magnitude, Direction = CFrame.new(AZ, TargetPosition)},
	}
	for i, v in pairs(Rays) do
		local Ray = ray:Clone()
		local Mesh = Ray.Mesh
		Mesh.Scale = (Vector3.new(0.15, 0.15, (v.Distance / 1)) * 5)
		Ray.CFrame = (v.Direction * CFrame.new(0, 0, (-0.5 * v.Distance)))
		game:GetService("Debris"):AddItem(Ray, (0.1 / (#Rays - (i - 1))))
		Ray.Parent = workspace
	end
	turret.Material = Enum.Material.Neon
end
game.Players.LocalPlayer.Character("Head").Reflectance = 0
game.Players.LocalPlayer.Character("Torso").Reflectance = 0
game.Players.LocalPlayer.Character("Right Arm").Reflectance = 0
game.Players.LocalPlayer.Character("Right Leg").Reflectance = 0
game.Players.LocalPlayer.Character("Left Arm").Reflectance = 0
game.Players.LocalPlayer.Character("Left Leg").Reflectance = 0
wait(1)
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
wait(0.01)
script:Destroy()

^ script that being cloned into the player

3 comments

0

Can you please post your other script that spams a lot of script inside Player?

0

i did, but the problem is i want the reflectance to be 0 and his walkspeed 0 when he stops being hit by the turret

0

You won't understand or fix it. because this is a turret and hard to do it