Destroy command not working in Trail script?
I have a gui that allows players to select a trail from a list. They have to click on a button to enable the trail and then a button will appear that allows them to disable it by destroying the trail. The enabling part works fine but the disabling/destroying part isn't. Please help me fix it.
The GUI is located in StarterGui and it contains Button1 which has the Enabling part, in a local script, and also Destroy1 button which has the Disabling part, also in a local script. When the trail is enabled, it will under the HumanoidRootPart.
Enabling Script:
01 | local player = game.Players.LocalPlayer |
02 | local give = script.Parent |
04 | give.MouseButton 1 Click:connect( function () |
05 | local character = player.Character |
06 | local trailClone = Instance.new( "Trail" , character.Head) |
07 | local HP = character.Head.NeckRigAttachment |
08 | local HRP = character.HumanoidRootPart.RootAttachment |
09 | local trailClone = Instance.new( "Trail" , character.Head) |
10 | trailClone.Parent = character.HumanoidRootPart |
11 | trailClone.Attachment 0 = HP |
12 | trailClone.Attachment 1 = HRP |
13 | trailClone.Lifetime = 1 |
15 | trailClone.TextureMode = "Stretch" |
16 | trailClone.TextureLength = 1 |
17 | trailClone.LightEmission = 0.2 |
18 | trailClone.Transparency = 0.5 |
19 | trailClone.MinLength = 0.1 |
20 | script.Parent.Parent.Destroy 1. Visible = true |
Disabling Script:
1 | local player = game.Players.LocalPlayer |
2 | local give = script.Parent |
4 | give.MouseButton 1 Click:connect( function () |
5 | local char = player.Character |
6 | char.HumanoidRootPart.Trail:Destroy() |
7 | script.Parent.Visible = false |