Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the particles only cloning to the lower torso? Any help?

Asked by 5 years ago
Edited 5 years ago

The particles are only cloning to the lower torso, but I want it to go to all the other mesh parts. Any help?

local Part = script.Parent
local Debounce = true

Part.Touched:Connect(function(player)
    if Debounce == true then
    local Character = player.Parent
    local RightUpperLeg = Character:WaitForChild("RightUpperLeg")
    local RightLowerLeg = Character:WaitForChild("RightLowerLeg")
    local RightFoot = Character:WaitForChild("RightFoot")
    local Poison1 = game.Workspace.Poison.PoisonSparkles:Clone()
    local Poison2 =game.Workspace.Poison.Poison:Clone()

    for i,v in pairs(Character:GetChildren()) do
        if v:IsA("MeshPart") then
            Poison1.Parent = v
            Poison2.Parent = v
        end
    end
    Debounce = false
    end
end)


1 answer

Log in to vote
0
Answered by
mc3334 649 Moderation Voter
5 years ago

hi, the reason you have this issue is because the particles are only cloned once. I think what you were thinking of is making a seperate function and returning a new particles every time. To fix your error, do this: (Easiest Way)

local Part = script.Parent
local Debounce = true

Part.Touched:Connect(function(player)
    if Debounce == true then
    local Character = player.Parent
    local RightUpperLeg = Character:WaitForChild("RightUpperLeg")
    local RightLowerLeg = Character:WaitForChild("RightLowerLeg")
    local RightFoot = Character:WaitForChild("RightFoot")
    local Poison1 = game.Workspace.Poison.PoisonSparkles
    local Poison2 =game.Workspace.Poison.Poison

    for i,v in pairs(Character:GetChildren()) do
        if v:IsA("MeshPart") then
            Poison1:Clone().Parent = v
            Poison2:Clone().Parent = v
        end
    end
    Debounce = false
    end
end)

or this: (What you were thinking of)

local Part = script.Parent
local Debounce = true

function P1()
    return game.Workspace.Poison.PoisonSparkles:Clone()
end
function P2()
    return game.Workspace.Poison.Poison:Clone()
end

Part.Touched:Connect(function(player)
    if Debounce == true then
    local Character = player.Parent
    local RightUpperLeg = Character:WaitForChild("RightUpperLeg")
    local RightLowerLeg = Character:WaitForChild("RightLowerLeg")
    local RightFoot = Character:WaitForChild("RightFoot")

    for i,v in pairs(Character:GetChildren()) do
        if v:IsA("MeshPart") then
            P1().Parent = v
        P2().Parent = v
        end
    end
    Debounce = false
    end
end)

I hope I was able to help. With further questions/comments/concerns, feel free to reply to my answer. Happy scripting! ~mc3334

0
Thank you so much! Definitely will remember this next time; I really learned from this. :) Microsoft_Net 21 — 5y
0
No Problem! mc3334 649 — 5y
Ad

Answer this question