This button in my GUI keeps duplicating the Trail after it's clicked more than once. The button is suppose to let the player get one Trail but it keeps duplicating the trail if the player clicks more than once.
local player = game.Players.LocalPlayer
local give = script.Parent
give.MouseButton1Click:connect(function()
local character = player.Character
local trailClone = Instance.new("Trail", character.Head)
local HP = character.Head.NeckRigAttachment
local HRP = character.HumanoidRootPart.RootAttachment
local trailClone = Instance.new("Trail", character.Head)
trailClone.Parent = character.HumanoidRootPart
trailClone.Attachment0 = HP
trailClone.Attachment1 = HRP
trailClone.Lifetime = 1
trailClone.Texture = "http://www.roblox.com/asset/?id=1311255790"
trailClone.TextureMode = "Stretch"
trailClone.TextureLength = 1
trailClone.LightEmission = 0.2
trailClone.Transparency = 0.5
trailClone.MinLength = 0.1
end)
Destroy script:
local player = game.Players.LocalPlayer
local give = script.Parent
give.MouseButton1Click:connect(function()
local char = player.Character
for _, v in pairs(char.HumanoidRootPart:GetChildren()) do if v.Name == "Trail" then v.Parent = nil end end
end)

1 comment
I added my script into your code and it works but it won't let me create another Trail after it's destroyed the first time.