game.Players.PlayerAdded:Connect(function(player)
local EquippedTrail = Instance.new("StringValue")
EquippedTrail.Name = "EquippedTrail"
EquippedTrail.Parent = player
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
player.CharacterAdded:Connect(function()
if EquippedTrail.Value ~= nil then
local TrailClone = game.ServerStorage:WaitForChild("Trails"):FindFirstChild(EquippedTrail.Value):Clone()
TrailClone.Name = "Trail"
TrailClone.Parent = player.Character
end
end)
end)
end)
EquippedTrail.Changed:Connect(function()
if EquippedTrail.Value ~= nil and game.ServerStorage:WaitForChild("Trails"):FindFirstChild(EquippedTrail.Value) then
if player.Character:FindFirstChild("Trail") then
player.Character.Trail:Destroy()
end
local TrailClone = game.ServerStorage:WaitForChild("Trails"):FindFirstChild(EquippedTrail.Value):Clone()
TrailClone.Name = "Trail"
TrailClone.Parent = player.Character
end
end)
end)
game.ReplicatedStorage.EquipTrail.OnServerEvent:Connect(function(player, TrailName)
if player:FindFirstChild("EquippedTrail") then
player.EquippedTrail.Value = TrailName
end
end)
game.ReplicatedStorage.UnequipTrail.OnServerEvent:Connect(function(player)
if player.Character:FindFirstChild("Trail") then
player.Character.Trail:Destroy()
end
if player:FindFirstChild("EquippedTrail") then
player.EquippedTrail.Value = ""
end
end)
you’re binding CharacterAdded, Died, and then CharacterAdded
you don’t want to do this, as it doesnt do anything the first death, but then every death after it, its binding another character added event
We do this with humanoid in character added because every character’s humanoid is different, and we have to re-bind them
This results in no trails for the first character,
after you die, the next character has one trail
after you die, the next character has two trails
after you die, the next character has three trails
after you die, the next character has four trails
long story short turn this
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
--in this case you don't need to bind anything to Died
--if you need to later then put your connection here
end)
if EquippedTrail.Value ~= nil then
local TrailClone = game.ServerStorage:WaitForChild("Trails"):FindFirstChild(EquippedTrail.Value):Clone()
TrailClone.Name = "Trail"
TrailClone.Parent = player.Character
end
end)
you need to make an attachment zero and attachment one in the character’s humanoid root part (or torso) and set the trail’s attachment zero and attachment one to it