Easy Code Not Working

Why isn’t the trail appearing in the head?

game.Players.PlayerAdded:Connect(function(player)
	print("Hi")
	player.CharacterAdded:Connect(function(char)
		print("Hello")
		local trail = game.ServerStorage.Trail:Clone()
		trail.Parent = char.Head
		print("Hey")
		local attachment0 = Instance.new("Attachment",char.Head)
		attachment0.Name=  "TrailAttachment0"
		local attachment1 = Instance.new("Attachment",char.HumanoidRootPart)
		attachment1.Name=  "TrailAttachment1"
		trail.Attachment0 = attachment0
		trail.Attachment1 = attachment1
	end)
end)

All prints work, and it prints Head, but it is not in the characters head.

1 Like

This has to be a plugin issue or something right? because ive talked to people and they say this code works for them.

i tried adding wait after player.CharacterAdded:Connect(function(char) and it worked. Character propably loads after the script executes.

As @pienter2 said, studio usually does the character load after the script can connect. See this thread for the entire explanation.

Have fun coding :smirk: