I’m trying to make a killstreak-kind of glove in my slap battles recreation by coding in all the phases and assigning particles to the players character, however every time a new phase is reached it works properly but every time I get a kill after it keeps duplicating the particle emitters when only one condition was met in my if and statement.
Screenshot of particles being duplicated (there should only be 1 aura, 1 aura2, and 1 aura3)
I’ve tried multiple solutions by adding a value in the character and looked at dev forum posts but none of them worked which is why I’m creating this topic.
The full script will be provided
Code: (FYI only phases 5 - 25 are added in)
-- GO TO LINE 78 FOR THE SECTION THAT DOESN'T WORK
local tool = script.Parent.Parent
local char = tool.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local anim = script:WaitForChild("slap")
local animT
local hitChars = {}
local d = false
local slapping = false
tool.Activated:Connect(function()
if d then
return print("debounce")
end
d = true
local h = tool.Parent.Humanoid
if not animT and not slapping then
animT = h:LoadAnimation(anim)
slapping = true
end
animT:Play()
wait(script.Cooldown.Value)
animT = nil
slapping = false
d = false
end)
tool.hitbox.Touched:Connect(function(hit)
if hitChars[hit.Parent] or not d then
return
end
if hit.Parent:FindFirstChild("Humanoid") then
local ec = hit.Parent
local plrc = tool.Parent
local ehr = ec:FindFirstChild("HumanoidRootPart")
local plrhr = plrc:FindFirstChild("HumanoidRootPart")
if ec:FindFirstChild("protected") then
return
end
if plrhr and ehr then
script.Disabled = true
ec.Humanoid.PlatformStand = false
local plr = game.Players:GetPlayerFromCharacter(tool.Parent)
plr.leaderstats.Slaps.Value = plr.leaderstats.Slaps.Value + 1
ec.Humanoid.Sit = true
local f = Instance.new("BodyVelocity", ehr)
f.MaxForce = Vector3.new(2,2,2) * math.huge
local dir = (ehr.CFrame.Position - plrhr.CFrame.Position).Unit
f.Velocity = (dir + Vector3.new(0,1,0)).Unit * script.Power.Value
local rot = Instance.new("BodyAngularVelocity", ehr)
rot.AngularVelocity = Vector3.new(1,1,1) * math.pi * 1
rot.MaxTorque = Vector3.new(2,2,2) * math.huge
rot.P = 5000
tool.Handle.slap:Play()
local plrHit = game.ServerStorage:WaitForChild("PlrHit")
if plrHit then
if ec:FindFirstChild("PlrHit") then
else
local cplrHit = plrHit:Clone()
cplrHit.Value = plrc.Name
cplrHit.Parent = ec
end
end
wait(0.35)
f:Destroy()
rot:Destroy()
ec.Humanoid.Sit = false
end
hitChars[hit.Parent] = true
wait(script.Stun.Value)
script.Disabled = false
hitChars[hit.Parent] = nil
end
end)
-- SECTION THAT DOESN'T WORK - v
local five = false
local ten = false
local twenty5 = false
local fifty = false
local seventy5 = false
local hundred = false
local particles = false
script.Kills.Changed:Connect(function(value)
if char.Head:FindFirstChild("NameUI") then
char.Head:FindFirstChild("NameUI").TextLabel.Text = tostring(value)
end
char.Humanoid.WalkSpeed = char.Humanoid.WalkSpeed + 1
script.Power.Value = script.Power.Value + 2
if script.Kills.Value >= 5 and script.Kills.Value <= 9 and five == false then
script.Parent.Attachment.FireParticle.Enabled = true
if char:FindFirstChild("Phase") == nil then
local phase = Instance.new("NumberValue", char)
phase.Name = "Phase"
phase.Value = 5
end
if char.Phase.Value == 5 and particles == false then
local pclone = game.ServerStorage:WaitForChild("Phase5"):Clone()
for i,v in pairs(pclone.Head:GetChildren()) do
v.Parent = char.Head
end
for i,v in pairs(pclone.Torso:GetChildren()) do
v.Parent = char.Torso
end
for i,v in pairs(pclone.LArm:GetChildren()) do
v.Parent = char["Left Arm"]
end
for i,v in pairs(pclone.RArm:GetChildren()) do
v.Parent = char["Right Arm"]
end
for i,v in pairs(pclone.LLeg:GetChildren()) do
v.Parent = char["Left Leg"]
end
for i,v in pairs(pclone.RLeg:GetChildren()) do
v.Parent = char["Right Leg"]
end
pclone:Destroy()
particles = true
end
five = true
elseif script.Kills.Value >= 10 and script.Kills.Value <= 24 and ten == false then
script.Parent.Attachment.Fire10.Enabled = true
char.Humanoid.WalkSpeed = 28
script.Power.Value = 75
if char.Phase.Value == 5 then
for i,v in pairs(char:GetChildren()) do
if v:IsA("BasePart") then
for i,v in pairs(v:GetChildren()) do
if v:IsA("ParticleEmitter") or v.Name == "Head" or v.Name == "Root" then
v:Destroy()
end
end
end
end
particles = false
char.Phase.Value = 10
end
if char.Phase.Value == 10 and particles == false then
local pclone = game.ServerStorage:WaitForChild("Phase10"):Clone()
for i,v in pairs(pclone.Head:GetChildren()) do
v.Parent = char.Head
end
for i,v in pairs(pclone.Torso:GetChildren()) do
v.Parent = char.Torso
end
for i,v in pairs(pclone.LArm:GetChildren()) do
v.Parent = char["Left Arm"]
end
for i,v in pairs(pclone.RArm:GetChildren()) do
v.Parent = char["Right Arm"]
end
for i,v in pairs(pclone.LLeg:GetChildren()) do
v.Parent = char["Left Leg"]
end
for i,v in pairs(pclone.RLeg:GetChildren()) do
v.Parent = char["Right Leg"]
end
pclone.Part.Head.Parent = char.Head
pclone.Part.Root.Parent = char.HumanoidRootPart
pclone:Destroy()
particles = true
end
ten = true
elseif script.Kills.Value >= 25 and script.Kills.Value <= 49 and twenty5 == false then
script.Parent.Attachment.Fire25.Enabled = true
char.Humanoid.WalkSpeed = 3
local pro = game.ServerStorage:WaitForChild("protected"):Clone()
pro.Parent = char
if char.Phase.Value == 10 then
for i,v in pairs(char:GetChildren()) do
if v:IsA("BasePart") then
for i,v in pairs(v:GetChildren()) do
if v:IsA("ParticleEmitter") or v.Name == "Head" or v.Name == "Root" then
v:Destroy()
end
end
end
end
particles = false
char.Phase.Value = 25
end
wait(10)
if char.Phase.Value == 25 and particles == false and char:FindFirstChild("Phase25") == false then
local pclone = game.ServerStorage:WaitForChild("Phase25"):Clone()
for i,v in pairs(pclone.Head:GetChildren()) do
v.Parent = char.Head
end
for i,v in pairs(pclone.Torso:GetChildren()) do
v.Parent = char.Torso
end
for i,v in pairs(pclone.LArm:GetChildren()) do
v.Parent = char["Left Arm"]
end
for i,v in pairs(pclone.RArm:GetChildren()) do
v.Parent = char["Right Arm"]
end
for i,v in pairs(pclone.LLeg:GetChildren()) do
v.Parent = char["Left Leg"]
end
for i,v in pairs(pclone.RLeg:GetChildren()) do
v.Parent = char["Right Leg"]
end
pclone:Destroy()
particles = true
end
char.Humanoid.WalkSpeed = 38
script.Power.Value = 100
twenty5 = true
elseif script.Kills.Value >= 50 and script.Kills.Value <= 74 and fifty == false then
fifty = true
script.Parent.Attachment.Fire50.Enabled = true
char.Humanoid.WalkSpeed = 50
script.Power.Value = 350
elseif script.Kills.Value >= 75 and script.Kills.Value <= 99 and seventy5 == false then
seventy5 = true
script.Parent.Attachment.Fire75.Enabled = true
char.Humanoid.WalkSpeed = 28
script.Power.Value = 45
elseif script.Kills.Value >= 100 and hundred == false then
hundred = true
script.Parent.Attachment.Fire100.Enabled = true
char.Humanoid.WalkSpeed = 100
script.Power.Value = 500
end
end)
Thanks for checking out this post and considering a solution if you’re replying!