How to find and destroy player trail

Hi im trying to make a script which destroys the players trail.
Im lost trying to figure out how to find the trail to destroy it.

Is there any scripts that find player trails and can destroy without having to make the trail a variable first?

Thankyou

2 Likes

Where is the trail located???

30 30

What do you mean? Do you have any reference?
Usually, you’d put the trail in player’s Head or HumanoidRootPart & add attachments there.

replicated storage but when player equips it, it clones

			
		local Trail = game.ReplicatedStorage.RainbowTrail

		local Head = character:FindFirstChild('Head') -- will wait until the head is loaded, at that time the code below will be yielded by this function, using waitforchild on something that doesnt exist will yield infinitely
		local Torso = character:FindFirstChild('Torso')
		local LowerTorso = character:FindFirstChild('LowerTorso') -- both has waistbackattachment
		local plrTrail = Trail:Clone()
		if Torso then
			plrTrail.Parent = Torso
			plrTrail.Attachment1 = Torso.WaistBackAttachment
		elseif LowerTorso then
			plrTrail.Parent = LowerTorso
			plrTrail.Attachment1 = LowerTorso.WaistBackAttachment
		end
		plrTrail.Attachment0 = Head.FaceFrontAttachment


	
		end

this is how t gets put onto player

where does the clone go?

Abcdefg

it goes onto the player

djabjfbjaj

just do

player.whereever it is.Trail:Destroy()
1 Like

You looking for something like this?

local player: Player = --insert player

for _,v: Trail in ipairs(player:GetDescendants()) do
	if not v:IsA("Trail") then
		continue
	end
	
	v:Destroy()
end
1 Like

Try using this:

local Torso = character:FindFirstChild('Torso')
local LowerTorso = character:FindFirstChild('LowerTorso')
if Torso then
	local Traill = Torso:FindFirstChild('RainbowTrail')
	if Traill then Traill:Destroy() end
elseif LowerTorso then
	local Traill = LowerTorso:FindFirstChild('RainbowTrail')
	if Traill then Traill:Destroy() end
end

it doesn’t check whether its inside a torso or a lowertorso

I don’t know where the trail is exactly

1 Like

see thats why im confused. When it clones it, it makes attachments to the character. But then i cant find them to destroy them in another script.

2 Likes

its either the torso or the lowertorso so using an if statement combined with findfirstchild works correctly

1 Like

this didnt work but gave me no errors

1 Like

this didnt work either, no errors tho

When it clones, can you try to find where the trail is in the Explorer?

its probably because there isnt a rainbowtrail
when using a waitforchild, it will yield infinitely (yielding for the max integer limit) unless its already assigned
whats the code before trying to destroy it?

found it! it goes to workspace.t3h1dy,LowerTorso.RainbowTrail

1 Like

what about this

local Torso = character:FindFirstChild('Torso')
local LowerTorso = character:FindFirstChild('LowerTorso')
if Torso then
	local Traill = Torso:WaitForChild('RainbowTrail')
	Traill:Destroy()
elseif LowerTorso then
	local Traill = LowerTorso:WaitForChild('RainbowTrail')
	Traill:Destroy()
end