#Obscure error 'exception while signaling: Must be a LuaSourceContainer'

1 messages · Page 1 of 1 (latest)

manic niche
#

It's not immediately evident what is causing this issue, as it sporadically occurs and has no stack trace.
However, I can guarantee the issue doesn't occur if I never enable this script.

local kart = script.Parent:WaitForChild("GoKart")
local regen_model = kart:Clone()

local rig
local cons = {}

local function regen()
    local new = regen_model:Clone()
    new.Parent = script.Parent

    rig(new)
end

rig = function(k)
    local chute = k:WaitForChild("KartChute")
    game.Debris:AddItem(chute, math.random(8, 12))

    for _,con in cons do con:Disconnect() end cons = {}

    -- Wrap signal connections in pcall and add error handling
    local success, err = pcall(function()
        table.insert(cons,k.Destroying:Connect(regen))
        table.insert(cons,k.AncestryChanged:Connect(function()
            if k.Parent == nil then
                regen()
            end
        end))
    end)
    if not success then
        warn("Error connecting signals:", err)
    end
end

-- Wrap rig function call in pcall and add error handling
local success, err = pcall(function()
    rig(kart)
end)
if not success then
    warn("Error in rig function:", err)
end

Despite wrapping the only execution points in pcall, the error occurs and is not caught, which I guess implies it's happening outside of the script somehow?
A clone of this script is created and then placed per new gokart variant and Enabled so it can execute after the parent has been initialized to workspace.

#

@nimble stump pls help

#

have u ran into this diarrhea error before

#
...
local new_kart = kart_variants[math.random(#kart_variants)]:Clone()
new_kart:PivotTo( CFrame.new(-3500 + math.random() * 7000, 200, -3500 + math.random() * 7000) )

local new_regen_script = script.KartRegenBase:Clone()
new_regen_script.Parent = new_kart

local new_occupant_script = script.OccupantAuthorityBase:Clone()
new_occupant_script.Parent = new_kart:WaitForChild("GoKart")

local new_chute = kart_chute:Clone()
new_chute.CFrame = new_kart.GoKart:WaitForChild("EngineBlock"):WaitForChild("CenterAttachment").WorldCFrame * CFrame.new(0, 10, 0)
new_chute.Parent = new_kart.GoKart

for _,attach in new_chute:GetChildren() do
    if not attach:IsA("Attachment") or attach.Name == "Center" then continue end
    local new_rope = Instance.new("RopeConstraint", attach)
    new_rope.Visible = true
    new_rope.Color = BrickColor.new("Institutional white")
    new_rope.Thickness = 0.2
    new_rope.Attachment0 = attach; new_rope.Attachment1 = new_kart.GoKart.EngineBlock.CenterAttachment
    new_rope.Length = 11.2
end

local align = new_chute.AlignOrientation:Clone()
align.Parent = new_kart.GoKart.PrimaryPart
align.Attachment0 = new_kart.GoKart.PrimaryPart.CenterAttachment

local vf = Instance.new("VectorForce", new_chute)
vf.Attachment0 = new_chute.Center
vf.RelativeTo = Enum.ActuatorRelativeTo.World
vf.Force = Vector3.new(0, (new_chute.AssemblyMass + new_kart.GoKart.EngineBlock.AssemblyMass) * workspace.Gravity * 0.99, 0)

new_kart.Parent = workspace.GoKartContainer

new_occupant_script.Enabled = true;
new_regen_script.Enabled = true;

table.insert(raceKarts_deployed, new_kart)
#

this is where in the code the new karts are actually instantiated, the whole of the func was too large to send so i ellipted the unimportant part

low kelp
#

My theory is that the script gets destroyed while attempting to run

manic niche
#

I also saw that thread

#

The thing is I deliberately added yielding to the regen script in case that was the cause

#

Am just really confused cuz it seems to just happen randomly, many of the karts spawn fine and have no issues

#

Probably gonna do away w the objects respawning themselves automatically, having a script per kart seems to be the issue

manic niche
#

The issue appears with or without pcalls, they weren't there when it initially occurred

nimble stump
#

remove the pcalls and show us the error message

#

and what line the errors are on

manic niche
#

that's what I'm telling you bruh it doesn't have any stack trace

#

it just says that in output

nimble stump
#

can i see a screenshot

manic niche
#

only difference is I threw in two warnings

warn("regen script started")

local kart = script.Parent:WaitForChild("GoKart")
local regen_model = kart:Clone()

warn("regen_model clone established")

local rig
local cons = {}

local function regen()
    local new = regen_model:Clone()
    new.Parent = script.Parent

    rig(new)
end

rig = function(k)

    for _,con in cons do con:Disconnect() end cons = {}

    -- Wrap signal connections in pcall and add error handling
    local success, err = pcall(function()
        table.insert(cons,k.Destroying:Connect(regen))
        table.insert(cons,k.AncestryChanged:Connect(function()
            if k.Parent == nil then
                regen()
            end
        end))
    end)
    if not success then
        warn("Error connecting signals:", err)
    end
    
end

-- Wrap rig function call in pcall and add error handling
local success, err = pcall(function()
    rig(kart)
end)
if not success then
    warn("Error in rig function:", err)
end
nimble stump
manic niche
#

bro 💀 I really didn't write it with pcalls to begin with, here is the exact same script with all pcalls commented and it does the exact same thing

warn("regen script started")

local kart = script.Parent:WaitForChild("GoKart")
local regen_model = kart:Clone()

warn("regen_model clone established")

local rig
local cons = {}

local function regen()
    local new = regen_model:Clone()
    new.Parent = script.Parent

    rig(new)
end

rig = function(k)

    for _,con in cons do con:Disconnect() end cons = {}

    -- Wrap signal connections in pcall and add error handling
    --local success, err = pcall(function()
        table.insert(cons,k.Destroying:Connect(regen))
        table.insert(cons,k.AncestryChanged:Connect(function()
            if k.Parent == nil then
                regen()
            end
        end))
    --end)
    --if not success then
    --    warn("Error connecting signals:", err)
    --end
    
end

-- Wrap rig function call in pcall and add error handling
--local success, err = pcall(function()
    rig(kart)
--end)
--if not success then
--    warn("Error in rig function:", err)
--end
nimble stump
#

Disable the script

#

And see if it still does it

manic niche
#

It doesn't do it if the script isn't enabled

nimble stump
#

Ok now comment out the script 1 line at a time

manic niche
#

I already went and put print("a") print("b") print("c") on every other line

#

when the error occurs, none print

nimble stump
#

Comment out each line

#

1 by 1

manic niche
#

print("a") would be on line 1 in this scenario

#

and it does not print if the error occurs

#

It seems to be outside the script's environment

obtuse mantle
#

Looks like the way you’ve set up the parent hierarchy is messing things up

#

The script is inside the kart, you’re then cloning the kart which also clones the script, then you’re tryna use the old script on the new kart but the old script’s parent is presumably nil if it’s being regenerated

manic niche
#

Actually the carts are contained in parent models

#

so it's like

#

new_kart
regenScript
kart to be cloned