Ad
Log in to vote
1

What does this output mean? Weld Parent Error

Asked by
Tesouro 407 Moderation Voter
7 years ago

I made this script:

function sit(child)
    if child.Name == "SeatWeld" then
        character = child.Part1.Parent
        if player.Value ~= character.Name then -- check if the player is the one I want
            child:Destroy()
        end
    end
end
script.Parent.ChildAdded:connect(sit)

It's supposed to destroy the seatweld when an undesired player sits, but when I tried to seat there, it didn't work and the output said this: Something unexpectedly tried to set the parent of SeatWeld to NULL while trying to set the parent of SeatWeld. Current parent is Seat. What is wrong? I didn't try to change it's parent, so why that error?

1 answer

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
7 years ago

This error happens when an event tries to remove something immediately after its parent is set. To get around it, add the weld to Debris instead:

game:GetService("Debris"):AddItem(child,0)
0
Hhmm... I don't know much about Debris service and stuff like that, so can I use a little wait()? Thanks btw. Tesouro 407 — 7y
0
adding wait() before changing its parent/removing it would also work. 1waffle1 2908 — 7y
Ad

Answer this question