The model doesn't get parented to my character when cloned

When I clone a model and parent it to the player, it doesn’t work.

image

It does print tho and says that its inside

	local function weld_torch(character)
		
		local ClonedTorch = Torch:Clone()
		local LeftHand = character:WaitForChild("LeftHand")
		ClonedTorch.Parent = LeftHand
		local Weld = Instance.new("Weld")
		Weld.Parent = LeftHand
		Weld.Part0 = LeftHand
		Weld.Part1 = ClonedTorch.PrimaryPart
		Weld.C0 = CFrame.Angles(math.rad(-90), 0, 0) + Vector3.new(0, -0.15, -0.5) --offset (vector3)
		print(character.Name, "torch cloned, welded, BUT NOT PARENTED YET")
		print("TORCH 100% COMPLETED")
		print("torch parent", ClonedTorch.Parent)
		print("lefthand parent",LeftHand.Parent)
	end
	
	if plr.Character then
		weld_torch(plr.Character)
	end
	
	plr.CharacterAdded:Connect(function(character)
		
		weld_torch(character)

thank you

I added a for loop to my script to see if its still a parent of the lefthand

	local function weld_torch(character)
		
		local ClonedTorch = Torch:Clone()
		local LeftHand = character:WaitForChild("LeftHand")
		local Weld = Instance.new("Weld", LeftHand)
		Weld.Part0 = LeftHand
		Weld.Part1 = ClonedTorch.PrimaryPart
		Weld.C0 = CFrame.Angles(math.rad(-90), 0, 0) + Vector3.new(0, -0.15, -0.5) --offset (vector3)
		print(character.Name, "torch cloned, welded, BUT NOT PARENTED YET")
		print("TORCH 100% COMPLETED")
		ClonedTorch.Parent = LeftHand
		for i = 1, 30 do
		print("torch parent", ClonedTorch.Parent)
		print("lefthand parent",LeftHand.Parent)
		wait(1)	
		end
	end

image
it becomes nil after a few seconds. The model way fallen out of the map, since its CanCollide off and Anchored off, but it doesnt explain why the weld doesnt appear in the lefthand

I modified the script to print the parent of Weld, ClonedTorch and LeftHand.
This is what I get:

image

All 3 become nil. Any idea to fix this?

I’m away from my computer right now but rest assured I’ll look into it.

Does this game only allow R15?

I have fixed the issue, dont worry. Thanks for help tho

Let everyone know your Solution (and mark the Solution as well) so it will others who have this issue in the future.

Okay, the solution was that the character was created, but not added to workspace as you can see from this image (loop of prints)

image

I fixed it by simply adding this at the beginning of the script

if not character.Parent then repeat task.wait() until character end

so it would yield until the character has been added to workspace.

2 Likes

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