Trail is not being removed on player

Before moving my trails to server storage, I was able to call Player.Character.Head.Trail:Destroy() and it worked perfectly fine. After moving everything over to ServerStorage so I can just clone the trails instead of using color sequence, it now throws me the error :
Trail is not a valid member of MeshPart "Workspace.player.Head

This is my code

	if Player.GameItems.ActiveTrail.Value ~= "" then
		Player.Character.Head.Trail:Destroy()
	end
	
	local TrailColors = {
			["Blue"] = ServerStorage:WaitForChild("Blue"),
			["Red"] = ServerStorage:WaitForChild("Red"),
			["Green"] = ServerStorage:WaitForChild("Green"),
			["Orange"] = ServerStorage:WaitForChild("Orange"),
			["Purple"] = ServerStorage:WaitForChild("Purple"),
			["Pink"] = ServerStorage:WaitForChild("Pink"),
			["Black"] = ServerStorage:WaitForChild("Black"),
			["White"] = ServerStorage:WaitForChild("White"),
			["Rainbow"] = ServerStorage:WaitForChild("Rainbow"),
		}

	local Character = Player.Character
	local Head = Character.Head
	
	local Trail = TrailColors[TrailColor]
	Trail = Trail:Clone()

	local Attachment0 = Instance.new("Attachment", Head)
	local Attachment1 = Instance.new("Attachment", Character.HumanoidRootPart)
	
	Attachment0.Name = "TrailAttachment0"
	Attachment1.Name = "TrailAttachment1"

	Trail.Attachment0 = Attachment0
	Trail.Attachment1 = Attachment1
	Trail.Parent = Head

I’m attaching the trail to the player’s head, and the if statement at the top will only trigger after the second time a player equips a trail, so there’s definately a trail attached, but it’s not being found. What’s the problem with the code? It worked fine with ColorSequences

1 Like

Is the Trail named Trail, or something else?

local TrailColors = {
	["Blue"] = ServerStorage:WaitForChild("Blue"),
	["Red"] = ServerStorage:WaitForChild("Red"),
	["Green"] = ServerStorage:WaitForChild("Green"),
	["Orange"] = ServerStorage:WaitForChild("Orange"),
	["Purple"] = ServerStorage:WaitForChild("Purple"),
	["Pink"] = ServerStorage:WaitForChild("Pink"),
	["Black"] = ServerStorage:WaitForChild("Black"),
	["White"] = ServerStorage:WaitForChild("White"),
	["Rainbow"] = ServerStorage:WaitForChild("Rainbow"),
}

This makes me think it’s not named “Trail” but something else

Looks like your are not renaming the trail when set in the player, either rename to trail or turn

into

if Player.GameItems.ActiveTrail.Value ~= "" then
		Player.Character.Head:FindFirstChild(Player.GameItems.ActiveTrail.Value):Destroy()
	end
2 Likes

Yeah I forgot that the actual trails in server storage are not named trails

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