Instances under script not being cloned

I have a server script in server script service which clones everything under the script:
image

However nothing is actually being cloned and no errors are given in the console and the game is R15, here is the code:

game.Players.PlayerAdded:Connect(function(player)

	player.CharacterAdded:Connect(function(character)

		for i,v in pairs(script:GetChildren()) do

			local interaction = v:Clone()
			interaction.Parent = character:WaitForChild("UpperTorso")

			if interaction.Name == "Main" then

				interaction.Disabled = false

			end

		end

	end)

end)

Nothing seems to be wrong with the code. Maybe try parenting it to the player’s HumanoidRootPart instead.

I don’t think that’ll fix it, but give it a shot anyways.

If that doesn’t work (which it probably won’t), then replace all of the code with this and tell me which part doesn’t print (if one of them doesn’t)

game.Players.PlayerAdded:Connect(function(player)
print("a")
	player.CharacterAdded:Connect(function(character)
print("b")
		for i,v in pairs(script:GetChildren()) do
print(i.." "..v.Name)
			local interaction = v:Clone()
			interaction.Parent = character:WaitForChild("HumanoidRootPart")
print("c")
			if interaction.Name == "Main" then

				interaction.Disabled = false
print("d")
			end

		end

	end)

end)

print("e")

all the letters are printed with all the instances names, except “e”

So I’m assuming they still didn’t clone, which might be why it’s not finishing the entire thing, but that wouldn’t make sense since it prints “d” AFTER it enables the script.

end
print("e")
		end
print("f")
	end)
print("g")
end)

print("h")

Replace the “ends” in your code with these.
I’m kinda confused since everything should be working.

Also sorry for any bad formatting. I’m at school on my phone right now, so it isn’t easy to do this lol

I added the new print statemented and even added 2 statements to print:

		local interaction = v:Clone()
			interaction.Parent = character:WaitForChild("UpperTorso")
			print(interaction.Parent)
			print(interaction.Parent.Parent)
			print("c")

Both the parent and parent.parent print as usual with the results being UpperTorso and NonStopEA8 (my character name), however once I’m in live explorer, none of the cloned instances can be found.

You’ll probably have to wait till I get home to use my computer. I can’t figure out at the moment. I’ll be a few hours, though.

If someone else offers help before I can help further, then you can divert your attention to them. I don’t mind!

Alright, I do really appreciate your help though even if you can’t come to a solution!

1 Like

before running your loop trying a while or repeat loop until the part you wish to clone the items into are loaded, it could be possible that you’re waitforchild gives up on waiting for the object to spawn and not clone it into the torso

Have you tried parenting them to an instance that isn’t the character?

and in the case that a repeat works, do

repeat task.wait() until character:FindFirstChild("UpperTorso")

And if you do not want any delays with this method you can always wrap a function for it in a coroutine.

Parenting to a part in the workspace does work however adding in

repeat task.wait() until character:FindFirstChild("UpperTorso")

into my code like this:

	player.CharacterAdded:Connect(function(character)
		repeat task.wait() until character:FindFirstChild("UpperTorso")

causes it to not work, with nothing being cloned into the UpperTorso

You’re 100% sure the “UpperTorso” is loading?

You could try a
player.CharacterAdded:Wait()

I’m sure the UpperTorso is loaded as, I inserted a print statement for interaction.Parent and it prints out UpperTorso.

True, I noticed. Are the items you’re trying to clone have the property Archivable enabled?

That might be it honestly. I forgot to ask that earlier. Archivable is such a useless property, for me at least.

In my 6 years of development on roblox, I’ve never used that property once

There are times I need to clone properties and parts of the player’s character occasionally, but that’s about the only time I’ve ever used it so far. (but that’s just a matter of disabling it so I can clone the data lol)

I’ve had friends do that in one of my group projects before, but it wasn’t me. I can’t think of a single time I’d ever use it in the games I make

Okay. I’m finally home now. Sorry I took so long


Do you mind sending me a place file so I can look at the game myself? Just makes it easier to help. You can send it via private message if you don’t want to publicly.
If not either way, it’s okay. I’ll still try my best to help!

Thank you to everyone that helped, I managed to solve the problem by going through my other scripts and tracked it down to a script that forced the player to wear the blocky package (which I’m guessing reset the torso after everything had been cloned inside) but once again, thank you to those who attempted to help, it was greatly appreciated.