Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What does this output mean? Weld Parent Error

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

✓ Accepted answer

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)

2 comments

0

Hhmm... I don't know much about Debris service and stuff like that, so can I use a little wait()? Thanks btw.

0

adding wait() before changing its parent/removing it would also work.

This discussion is preserved as it was. New answers, comments, and votes are closed.