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

Why isn't my trail getting destroyed?

Asked by 5 years ago
Edited 5 years ago

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)

0
Yeah, it's because you're doing it on the client. I would recommend using a RemoteEvent so that the server takes care of making the trail nil. DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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.

Ad

Answer this question