Torch not welding for all players

The torch doesn’t get welded to all the players in game, but it does work in studio.


(everyone is supposed to have a torch welded to their left hand)

	plr.CharacterAdded:Connect(function(character)
		
		--Welds the torch to the left hand
		local ClonedTorch = Torch:Clone()
		local LeftHand = character:FindFirstChild("LeftHand")
		local Weld = Instance.new("WeldConstraint")
		Weld.Parent = LeftHand
		Weld.Part0 = LeftHand
		Weld.Part1 = ClonedTorch.PrimaryPart
		ClonedTorch:PivotTo(LeftHand.CFrame * 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")
		ClonedTorch.Parent = LeftHand
		print("TORCH 100% COMPLETED")
		print("torch position", ClonedTorch.PrimaryPart.Position)
		print("lefthand position",LeftHand.Position)

I tried to make it print to see if its a welding issue, but it doesnt print anything in the dev console in game when the characters gets added

RECAP: NOT EVERYONE HAS A TORCH WELDED TO THEIR LEFTHAND WHEN IT’S SUPPOSED TO HAPPEN

What would be the best way to fix it?


in studio, it gets printed and the torch works for everyone

In game, it only works for me, not everyone

Seems like you need to also consider characters that are already in the game when you join, this only considers the situation where new characters are added after you join.

Additionally, I would imagine you might also need to WaitForChild on the left hand, since that might not exist immediately as the character is added, I can’t remember if that’s ever the case though.

but isnt CharacterAdded ran when a new character joins the game and it scripts gets ran using them as the player no?

and if it doesnt exist, there would be an error no?

I suppose I don’t fully understand the issue. Are you the first player to join the server and subsequent players who join are not getting a torch? If that’s the case I would be curious when you connect to the CharacterAdded event. Could you show more of your code?

You’re correct there, yeah. If it didn’t exist it would error.

looks like I (woitur) am the ONLY one who gets the torch whether I or someone else joins the server first

My alt joined the server before I did and still didnt receive the torch while I did

image

Good to know. Can I see the code where you’re connecting to CharacterAdded? How are you getting the plr variable?

game:GetService("Players").PlayerAdded:Connect(function(plr)
	local PlayerStats = Instance.new("Folder")
	PlayerStats.Name = "PlayerStats"
	PlayerStats.Parent = plr
	
	local Inventory = Instance.new("Folder")
	Inventory.Name = "Inventory"
	Inventory.Parent = plr
	
	
	
	
	plr.CharacterAdded:Connect(function(character)
		
		--Welds the torch to the left hand
		local ClonedTorch = Torch:Clone()
		local LeftHand = character:WaitForChild("LeftHand")
		local Weld = Instance.new("WeldConstraint")
		Weld.Parent = LeftHand
		Weld.Part0 = LeftHand
		Weld.Part1 = ClonedTorch.PrimaryPart
		ClonedTorch:PivotTo(LeftHand.CFrame * 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")
		ClonedTorch.Parent = LeftHand
		print("TORCH 100% COMPLETED")
		print("torch position", ClonedTorch.PrimaryPart.Position)
		print("lefthand position",LeftHand.Position)
		
		local Humanoid = character:FindFirstChildWhichIsA("Humanoid")

thats all the code that is related to CharacterAdded before the Humanoid.Died event

Can you try something like this:

game:GetService("Players").PlayerAdded:Connect(function(plr)
	local PlayerStats = Instance.new("Folder")
	PlayerStats.Name = "PlayerStats"
	PlayerStats.Parent = plr

	local Inventory = Instance.new("Folder")
	Inventory.Name = "Inventory"
	Inventory.Parent = plr

	
	local function handle_new_character(character)
		local ClonedTorch = Torch:Clone()
		local LeftHand = character:WaitForChild("LeftHand")
		local Weld = Instance.new("WeldConstraint")
		Weld.Parent = LeftHand
		Weld.Part0 = LeftHand
		Weld.Part1 = ClonedTorch.PrimaryPart
		ClonedTorch:PivotTo(LeftHand.CFrame * 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")
		ClonedTorch.Parent = LeftHand
		print("TORCH 100% COMPLETED")
		print("torch position", ClonedTorch.PrimaryPart.Position)
		print("lefthand position",LeftHand.Position)

		local Humanoid = character:FindFirstChildWhichIsA("Humanoid")
	end

	
	if (plr.Character) then
		handle_new_character(character)
	end
	
	plr.CharacterAdded:Connect(function(character)

		handle_new_character(character)

I’m curious if the character is already loaded before you connect to the event online. Also I know there’s some code missing there so you’ll need to fill in the blanks with your code.

	local function weld_torch(character)
		local ClonedTorch = Torch:Clone()
		local LeftHand = character:WaitForChild("LeftHand")
		local Weld = Instance.new("WeldConstraint")
		Weld.Parent = LeftHand
		Weld.Part0 = LeftHand
		Weld.Part1 = ClonedTorch.PrimaryPart
		ClonedTorch:PivotTo(LeftHand.CFrame * 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")
		ClonedTorch.Parent = LeftHand
		print("TORCH 100% COMPLETED")
		print("torch position", ClonedTorch.PrimaryPart.Position)
		print("lefthand position",LeftHand.Position)

		local Humanoid = character:FindFirstChildWhichIsA("Humanoid")
	end
	
	if plr.Character then
		weld_torch(plr.Character)
	end
	
	plr.CharacterAdded:Connect(function(character)
		
		weld_torch(character)
		
		local Humanoid = character:FindFirstChildWhichIsA("Humanoid")

thats what I did, it works for me in studio, ima have to try it ingame with an alt

is this what you wanted?

1 Like
game:GetService("Players").PlayerAdded:Connect(function(plr)
	local PlayerStats = Instance.new("Folder")
	PlayerStats.Name = "PlayerStats"
	PlayerStats.Parent = plr
	
	local Inventory = Instance.new("Folder")
	Inventory.Name = "Inventory"
	Inventory.Parent = plr
	
	
	local function weld_torch(character)
		local ClonedTorch = Torch:Clone()
		local LeftHand = character:WaitForChild("LeftHand")
		local Weld = Instance.new("WeldConstraint")
		Weld.Parent = LeftHand
		Weld.Part0 = LeftHand
		Weld.Part1 = ClonedTorch.PrimaryPart
		ClonedTorch:PivotTo(LeftHand.CFrame * 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")
		ClonedTorch.Parent = LeftHand
		print("TORCH 100% COMPLETED")
		print("torch position", ClonedTorch.PrimaryPart.Position)
		print("lefthand position",LeftHand.Position)
	end
	
	if plr.Character then
		weld_torch(plr.Character)
	end
	
	plr.CharacterAdded:Connect(function(character)
		
		weld_torch(character)
		
		local Humanoid = character:FindFirstChildWhichIsA("Humanoid")

full script

image
still the same issue, my alt joined before my main and still nothing.

Yes, I did publish it

Does it output anything online about the torch for the other player?

thats for when I join (main account alone)

thats for when my alt joins the server where my main is


it gets printed, but the torch doesnt appear for some reason

Okay. I’m wondering if maybe the WeldConstraint is causing some strange behavior. You could try a Weld instead and set the C0 on the weld to CFrame.Angles(math.rad(-90), 0, 0) + Vector3.new(0, -0.15, -0.5) and I think that will give the same result? You won’t need to call PivotTo on the ClonedTorch with that.

My thought is that maybe the torch IS there, just not in the position you’re expecting.

	local function weld_torch(character)
		local ClonedTorch = Torch:Clone()
		local LeftHand = character:WaitForChild("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")
		ClonedTorch.Parent = LeftHand
		print("TORCH 100% COMPLETED")
		print("torch position", ClonedTorch.PrimaryPart.Position)
		print("lefthand position",LeftHand.Position)
	end

something like that?

Yeah I think that looks correct. Give it a try :+1:

image
my alt doesn’t get anything


I do get it, but my alt doesnt

now it prints out that the torch is very far, but it works for me, not my alt