Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I delete a trail after it is equipped? [closed]

Asked by 5 years ago
Edited 5 years ago

I am making a trail shop and I can't figure out how to delete a player's trail after they've equipped it. I want to use this so that when a player equips a trail, any other trail they currently have equipped is deleted so that they can't wear two trails at once. Here's what I have so far. Trail is a remote event and wantedtrail is a variable that holds a trail. There are two identical blocks of code because one is for equipping a trail immediately and the other is for equipping a trial after the player respawns.

script.Trail.OnServerEvent:Connect(function(plr, wantedtrail)

local trail = game.ReplicatedStorage[wantedtrail]:Clone()
trail.Parent = plr.Character.Head
local at0 = Instance.new("Attachment",plr.Character.Head)
at0.Name = "TrailAttachment0"
local at1 = Instance.new("Attachment",plr.Character.HumanoidRootPart)
at1.Name = "TrailAttachment1"
trail.Attachment0 = at0
trail.Attachment1 = at1

plr.CharacterAdded:Connect(function(char)
    local trail = game.ReplicatedStorage[wantedtrail]:Clone()
    trail.Parent = plr.Character.Head
    local at0 = Instance.new("Attachment",plr.Character.Head)
    at0.Name = "TrailAttachment0"
    local at1 = Instance.new("Attachment",plr.Character.HumanoidRootPart)
    at1.Name = "TrailAttachment1"
    trail.Attachment0 = at0
    trail.Attachment1 = at1
end)

end)

Please help.

Closed as Not Constructive by DinozCreates, xPolarium, and theking48989987

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?