For i, x in pairs(workspace:GetChildren()) do is not working for cloned parts from the serverstorage

Title says all. I need help
code is working for the models that they already in the workspace. Also the script in the serverscriptservice

				for b, seat in pairs(kizak:GetChildren()) do
					if seat.Name == "seat" then
						seat.ChildRemoved:connect(function()
							local a = seat:FindFirstChild("SeatWeld")
							if a ~= nil then end
							print(seat.Parent.Name)
							kizak:remove()

If you iterate the children of the workspace before instances are added to it, the new instances won’t be iterated.

1 Like

What error messages do you get? What does the clone code look like?

You meant to say if not a then return end?

Also:

Use :Destroy() and :Connect() instead.

there are no error messages… …

No error is a message too. It means the code works. You need to run this code AFTER you add the children. It would help in studio if you can visually confirm the children have been added on the server side.

as you Said the code runs when player sits on the seat. that means the children have been added

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.