#Emitting Function Erroring

1 messages · Page 1 of 1 (latest)

rotund hull
#
function module.Emit(Ins : Instance, Recursive : boolean?, DestroyOnFinish : boolean)
    if DestroyOnFinish then
        local con = Ins.ChildRemoved:Connect(function()
            if #Ins:GetChildren() == 0 then
                Ins:Destroy()
            end
        end)
        task.delay(15,con.Disconnect,con)
    end
    for _, child : Instance in (if Recursive then Ins:GetDescendants() else Ins:GetChildren()) do
        if child:IsA("ParticleEmitter") then
            task.delay(child:GetAttribute("EmitDelay") or 0,child.Emit,child,child:GetAttribute("EmitCount") or 1)
            if DestroyOnFinish then
                task.delay((child:GetAttribute("EmitDelay") or 0) + child.Lifetime.Max,child.Destroy,child)
            end
        end
    end
end

I'm not sure if i've been looking at studio for too long, but i actually cannot even understand with this error is saying to me right now

surreal void
#

I think you’re passing a number for the Ins argument, can I see you call the function?

rotund hull
#
local effect = script.LMB:Clone()
local RS = game:GetService("ReplicatedStorage")
local BF = require(RS.Modules.BaseFunctions)

return function(CFrame)
    effect.Parent = workspace.ServerFX
    effect.CFrame = CFrame
    for object in effect:GetChildren() do
        BF.Emit(object, true, true)
    end
end
```using a module to do it
surreal void
#

Alright

rotund hull
#

realizing i shouldn't even need to do it with a for loop since i made it recursive

surreal void
#

True

#

Oh

plucky forgeBOT
#

studio** You are now Level 6! **studio

surreal void
#

I see it

#

You are going for object in effect:GetChildren()

#

Instead do for index, object in effect:GetChildren()

#

since looping also gives you the number of that child

rotund hull
#

yeah i fixed up that whole section rq

#
return function(CFrame)
    effect.Parent = workspace.ServerFX
    effect.CFrame = CFrame
    BF.Emit(effect, true, true)
end
```it's just this now, however
#

it doesn't error

#

which is good

#

but

surreal void
#

But?

rotund hull
surreal void
#

Hmm I don’t see the error

#

Looking at it on my phone is pain lol

rotund hull
#

💀

#

sorry for your loss

surreal void
#

Thanks bro I need that

#

I’m sorry dude I don’t see why the code isn’t working, I think we’ve both been on studio for too long

#

But like check out the serverFx folder

rotund hull
#

yeah im so

#

confused man

#

💀

surreal void
#

Make sure it’s been copied properly

surreal void
rotund hull
#

where did the emitters go.

#

😭

surreal void
#

That’s one heck of a question dude

#

But at least we know what’s wrong

rotund hull
#

indeed

surreal void
#

Hmm

rotund hull
#

okay

#

maybe it's cause the emitters are getting destroyed frame 1

surreal void
#

By what script?

#

Oh wait

#

Yeah I get what you mean

rotund hull
#

task.delay((child:GetAttribute("EmitDelay") or 0) + child.Lifetime.Max,child.Destroy,child)?

surreal void
#

Yeah

#

Do you have those attributes set?

#

EmitDelay?

rotund hull
#

lifetime yeah

#

emitdelay nah

surreal void
#

Well there we have it

rotund hull
#

but it's doing the addition tho

surreal void
#

Oh yeah

#

Dude I just spotted that

rotund hull
#

like if there's no delay it sets it to 0 and then adds how long it's meant to live so like

#

what the hell

#

aight imma repick this up in a bit 😭

#

if you have any ideas lemme know

surreal void
#

I will

#

Wait dude

rotund hull
#

wsp

surreal void
#

Wait i gotta double check my bad

rotund hull
#

ur good

plucky forgeBOT
#

studio** You are now Level 8! **studio

surreal void
#

It might be because the particle emittors are disabled (enabled = false)

#

I’m a bit unsure as I haven’t used them in a while