when the script is reproduced, it applies the changes to the npc one by one, I really know where the problem is but I don’t know how to solve it. Please help
This is the code
local atmosfera = game.ReplicatedStorage.Habilities.Slayer.R.AtmosphereScary:Clone()
atmosfera.Parent = game.Lighting
for i,v in pairs(workspace:GetChildren()) do
local hum = v:FindFirstChild("Humanoid")
if hum then
if hum.Parent.Name ~= character.Name then
local part = game.ReplicatedStorage.Habilities.Slayer.R.Asustado.Asustado.BlackHole:Clone()
local gui = game.ReplicatedStorage.Habilities.Slayer.R.Asustado.BillboardGui:Clone()
local target = game.ReplicatedStorage.Habilities.Slayer.R.Target:Clone()
if (character.HumanoidRootPart.Position - hum.Parent.HumanoidRootPart.Position).magnitude <= 100 then
target.Parent = hum.Parent.HumanoidRootPart
part.Parent = hum.Parent.Head
gui.Parent = hum.Parent.Head
hum.WalkSpeed = 0
hum.JumpPower = 0
hum.Parent.IsBlocking.Value = 0
wait(2)
calaveras:Destroy()
circulo:Destroy()
cara:Destroy()
wait(5)
hum.WalkSpeed = 16
hum.JumpPower = 50
target:Destroy()
part:Destroy()
gui:Destroy()
atmosfera:Destroy()
end
end
end
end
I leave a video in case I have not explained it well
You could wrap code starting from third line into delay(nil,function() your code lines 3-34 end) so it will run in separated thread and will not stuck by each other
delay(nil, function()
for i,v in pairs(workspace:GetChildren()) do
local hum = v:FindFirstChild("Humanoid")
if hum then
if hum.Parent.Name ~= character.Name then
local part = game.ReplicatedStorage.Habilities.Slayer.R.Asustado.Asustado.BlackHole:Clone()
local gui = game.ReplicatedStorage.Habilities.Slayer.R.Asustado.BillboardGui:Clone()
local target = game.ReplicatedStorage.Habilities.Slayer.R.Target:Clone()
if (character.HumanoidRootPart.Position - hum.Parent.HumanoidRootPart.Position).magnitude <= 100 then
target.Parent = hum.Parent.HumanoidRootPart
part.Parent = hum.Parent.Head
gui.Parent = hum.Parent.Head
hum.WalkSpeed = 0
hum.JumpPower = 0
hum.Parent.IsBlocking.Value = 0
wait(2)
calaveras:Destroy()
circulo:Destroy()
cara:Destroy()
wait(5)
hum.WalkSpeed = 16
hum.JumpPower = 50
target:Destroy()
part:Destroy()
gui:Destroy()
atmosfera:Destroy()
end
end
end
end
end)
for i,v in pairs(workspace:GetChildren()) do
delay(nil, function()
local hum = v:FindFirstChild("Humanoid")
if hum then
if hum.Parent.Name ~= character.Name then
local part = game.ReplicatedStorage.Habilities.Slayer.R.Asustado.Asustado.BlackHole:Clone()
local gui = game.ReplicatedStorage.Habilities.Slayer.R.Asustado.BillboardGui:Clone()
local target = game.ReplicatedStorage.Habilities.Slayer.R.Target:Clone()
if (character.HumanoidRootPart.Position - hum.Parent.HumanoidRootPart.Position).magnitude <= 100 then
target.Parent = hum.Parent.HumanoidRootPart
part.Parent = hum.Parent.Head
gui.Parent = hum.Parent.Head
hum.WalkSpeed = 0
hum.JumpPower = 0
hum.Parent.IsBlocking.Value = 0
wait(2)
calaveras:Destroy()
circulo:Destroy()
cara:Destroy()
wait(5)
hum.WalkSpeed = 16
hum.JumpPower = 50
target:Destroy()
part:Destroy()
gui:Destroy()
atmosfera:Destroy()
end
end
end
end)
end