This script is suppose to allow players to put on a Trail but the problem I'm having is that if the player clicks the Unequip button to remove the Trail, then they can't click on the Trail button to put another one on.
Trail button script:
local player = game.Players.LocalPlayer
local give = script.Parent
local trail = false
give.MouseButton1Click:connect(function()
if trail then return end
trail = true
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)
This is the script that removes the Trail when the player clicks the Unequip button:
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)
Please help if you can! Thanks in advance.
