Keep trail on respawn

Hi guys! I am having trouble with keeping trails on respawn, if i die or reset, the trail disappears.

Here’s the bit of the script with the issue.

elseif not buying and plr.OwnedTrails:FindFirstChild(trail.Name) then
		
		local char = plr.Character
		
		if not char or not char:FindFirstChild("HumanoidRootPart") then return end
		
		for i, child in pairs(char.HumanoidRootPart:GetChildren()) do
			
			
			if child:IsA("Trail") then child:Destroy() end
		end
		
		
		local newTrail = trail:Clone()

		newTrail.Attachment0 = char.HumanoidRootPart.TrailTop
		newTrail.Attachment1 = char.HumanoidRootPart.TrailBottom

		newTrail.Parent = char.HumanoidRootPart
	end
end)

The script is from @Sub2HTR by the way.

just do smth like:

Player.CharacterAdded:connect(function(char)
		repeat wait() until char:FindFirstChild'Humanoid' and char:FindFirstChild'HumanoidRootPart'
		for i, child in pairs(char.HumanoidRootPart:GetChildren()) do
			if child:IsA("Trail") then child:Destroy() end
		end
		local newTrail = trail:Clone()
		newTrail.Attachment0 = char.HumanoidRootPart.TrailTop
		newTrail.Attachment1 = char.HumanoidRootPart.TrailBottom
		newTrail.Parent = char.HumanoidRootPart
end)

it doesnt work, it literally broke the whole script rip

can you post the error. so i can help further.

Just noticed you got this code from @Sub2HTR. He has made a video of a Tower of Hell open-sourced game that contains a trail shop that was modified, that includes a feature where the trail saves when the player resets just like how you mentioned it. You can check it out here, and see the contents for yourself:

2 Likes

thanks for replying, but the gui doesnt even work
dont worry, i’ll just delete the trail gui and scripts but thank you so much for ur help! ill mark your post as the solution. have a good day :upside_down_face:

1 Like

As u can see, the shop doesn’t even work

May I see the ShopHandler and TrailManager scripts?