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.
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.
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.
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.