Hello all I want is my script to make all of these blocks(1) to spit out a particle all at the same time they are all the same and all are in the same model(2) they also have the same particle emitter. But my script is only enabling and disabling one particle emitter.
local PE = game.workspace.AOE_sword_sparkles. --problem area (or at least I think it's here)
while true do
wait(5)
PE.Enabled = true
wait(0.5)
PE.Enabled = false
print("Please wait")
end
You can loop through all of the descendants of the model, then find out if any of the descendants are particle emitters, then enable/disable them:
while true do
wait(5)
for i, v in pairs(AOE_sword_sparkles:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Enabled = true
end
end
wait(0.5)
for i, v in pairs(AOE_sword_sparkles:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Enabled = false
end
end
print("Please wait")
end
The reason is because AOE_sword_sparkles is not defined yet. To define it, make it a variable:
local AOE_sword_sparkles = game.workspace.AOE_sword_sparkles
then put that in your code:
local AOE_sword_sparkles = game.workspace.AOE_sword_sparkles
while true do
wait(5)
for i, v in pairs(AOE_sword_sparkles:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Enabled = true
end
end
wait(0.5)
for i, v in pairs(AOE_sword_sparkles:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Enabled = false
end
end
print("Please wait")
end
You can use GetChildren(), but the model has more than 1 layer of children.
The code would look like this if you were to use GetChildren(), notice how much longer it is:
local AOE_sword_sparkles = game.workspace.AOE_sword_sparkles
for i, v in pairs(AOE_sword_sparkles:GetChildren()) do
for i, w in pairs(v:GetChildren()) do
if w:IsA("ParticleEmitter") then
v.Enabled = true
end
end
end
compared to GetDescendats():
local AOE_sword_sparkles = game.workspace.AOE_sword_sparkles
for i, v in pairs(AOE_sword_sparkles:GetDescendants()) do
if v:IsA("ParticleEmitter") then
v.Enabled = true
end
end