How would I add an attachment into a character's left hand?

Hello. I have been having a problem with inserting an attachment into a character’s hand.
Here is my current script:

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local LeftHand = Character:WaitForChild("LeftHand")
		local Attachment = Instance.new("Attachment",LeftHand)
		Attachment.Name = "Attachment1"
	end)
end)

As you most likely see there are no mistakes here. (Unless i’m blind)

When I run this I open the character’s left hand and this is what I see

Screen Shot 2020-08-07 at 19.28.39

I don’t find the attachment called “Attachment1” anywhere inside of the player’s left hand.

I have contacted many developers and nobody seems to know how to fix this. (I’m pretty sure none of the people here can help me)

Thanks for any help I can receive.

1 Like

I tried this out myself, and it worked fine.
image

Where are you running this Script?

I am running this script in ServerScriptService.

Ensure it is parented to a server script in server script service.

It is a server script inside ServerScriptService.

This could possibly be a problem with the roblox explorer not updating. Try referencing the Attachment from a Script and see if you can find it.

I have tried to print(Attachment.Parent) and it did print “LeftHand”.

Ok try doing this:

local function OnCharacterAdded(Character)
      Player.CharacterAdded:Connect(function(Character)
		local LeftHand = Character:WaitForChild("LeftHand")
		local Attachment = Instance.new("Attachment",LeftHand)
		Attachment.Name = "Attachment1"
	end)
end
game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(OnCharacterAdded)
end)
for _, Player in ipairs(game.Players:GetPlayer()) do
    local Character = Player.Character or Player.CharacterAdded:Wait()
    OnCharacterAdded(Character)
end
1 Like

In this case, it seems like it’s just a problem with roblox’s explorer being lazy. I have had this same issue before. I wouldn’t worry about it, as long as it prints fine and you can still reference it from code.

You may be experiencing this issue:

If this really bugs you a lot, try restarting studio. It often whips the explorer back into shape.

2 Likes

Try publishing the place to roblox, and restarting studio that happens sometimes.

1 Like

Maybe try adding a delay?

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
	     Character:WaitForChild("LeftHand")
	     local Attachment = Instance.new("Attachment")
	     Attachment.Name = "Attachment1"
	     wait(5)
	     Attachment.Parent = Character.LeftHand
    end)
end)

Thanks for the help everyone. I have figured Client Explorer does not update properly for me.
Screen Shot 2020-08-07 at 20.06.16
It does print attachment1 which means the script has found the attachment.
Screen Shot 2020-08-07 at 20.08.38

Thanks for the help.