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

Assigning C1 to a weld not doing anything in my script?

Asked by 5 years ago

So I have a script, and I'm trying to make a cool lightning body effect. I managed to get what I was looking for, but the meshes kind of dragged back when I moved, so I decided to try welding it and changing the C1 instead of just changing the meshes' CFrames.

My goal was to have the lightning meshes placed randomly around each part of the player's body all the while being welded to the parts, but changing the C1 of the welds doesn't seem to do anything. I do know the C1 is changing though, thanks to a print test, it's just not changing the position of the meshes.

Without Welds: https://gyazo.com/dcd1ce6203874895d51866620f16ff91

With Welds: https://gyazo.com/48944708dcb93c180b64d81ceb4d6394

Script:

-- Varaibles
local part = script.Parent

for i,v in pairs(part:GetChildren()) do
    if v.ClassName == "MeshPart" then

        local weld = Instance.new("Weld",v)
        weld.Name = v.Name
        weld.Part0 = part
        weld.Part1 = v

    end
end

-- Lightning Effect
while wait() do

    local spread = (part.Size.X + part.Size.Y + part.Size.Z)/3

    for i,v in pairs(part:GetChildren()) do
        if v.ClassName == "MeshPart" then

            local weld = v:FindFirstChild(v.Name)
            v.Transparency = 1

            if weld then
                weld.C1 = CFrame.new(math.random(-spread,spread),math.random(-spread,spread),math.random(-spread,spread)) * CFrame.fromEulerAnglesXYZ(math.random(0-(math.pi*2),(math.pi*2)),math.random(0-(math.pi*2),(math.pi*2)),math.random(0-(math.pi*2),(math.pi*2)))
            end
            wait()

            v.Transparency = 0

        end
    end
end
0
Bro we talked about using the while wait() do idiom. Also please call wait with a reasonable time, not a short as hell number like 0.05, and especially not without argument User#24403 69 — 5y
0
Geez your attitude man. 1: I made the wait that short because that's just how fast lightning is. 2: I already told you that I understand what while wait() do means, so why not just use it? And 3: That comment was totally off topic. If you're gonna leave a comment, actually talk about the question and don't get so pissed off over such a dumb thing. Knineteen19 307 — 5y
0
I asked for assistance fixing something with my welds, not you complaining about things that wouldn't make a difference either way. Knineteen19 307 — 5y

Answer this question