This is my 5th attempt at destroying a trail when the gui button gets clicked. I used alot of different methods but I can't get it to work. Basically when a button is clicked a trail is inserted into the player but I got multiple buttons for different trails. So I want to remove the current trail(s) by clicking on another gui button. FilteringEnabled is on btw, If you could please give me a solution with and without FilteringEnabled.
local plr = game.Players.LocalPlayer
local char = plr.Character
script.Parent.MouseButton1Click:Connect(function()
for i,v in pairs (char:GetChildren()) do
if v:IsA("Trail") then
v:Destroy()
end
end
end)
Using a localscript will only show/remove the trail for you, but others will be able to see the trail. This is because guis are client-sided, try using a RemoteEvent to fire a server request so that everyone will be able to see it if you haven't already.
Note that exploiters can use a RemoteEvent to fire the same server request as it's set to.