I'm trying to make a script that removes all accessories when the player joins the game and works with Filtering enabled. I am using remote events but they are not firing.
-- This is in a local script
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local RemoveAccessoriesEvent = ReplicatedStorage.Events:WaitForChild("RemoveAccessoriesEvent")
RemoveAccessoriesEvent:FireServer()
-- This is in a server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoveAccessoriesEvent = ReplicatedStorage.Events.RemoveAccessoriesEvent
local function onRemoveAccessoriesFired(player)
warn("RemoveAccessoriesEvent has been fired") --// Not showing which means the event is not being fired
local char = player.Character
while true do
wait(0.1)
for i,v in pairs(char:GetChildren())do
if v.ClassName == "Accessory"and v.Name~="Blonde"and v.Name~="Cyan"and v.Name~="Green"and v.Name~="MidnightBlue"and v.Name~="Normal"and v.Name~="Pastel"and v.Name~="PatrioticShaggy"and v.Name~="Purple"and v.Name~="Rainbow"and v.Name~="Recycled"and v.Name~="Red"and v.Name~="Shaggy2"and v.Name~="Tix"and v.Name~="auburn"and v.Name~="neonpink" then
v:Destroy()
end
end
end
end
RemoveAccessoriesEvent.OnServerEvent:Connect(onRemoveAccessoriesFired)

3 comments
Is the LocalScript in StarterPlayerScripts and the Script in ServerScriptService? If either are in ReplicatedStorage, they will not run. Are either of the scripts Disabled? Put a print before and after you call FireServer on the LocalScript, to confirm it fires. Do you have any other error messaages in the Output?
So I get an error saying attempt to index local 'char' (a nil value)
This means that at the time the RemoteEvent is fired, the Character has not loaded. local char = player.CharacterAdded:Wait()