So, I've trying to make an anti-backdoor script so that it will check every remote in ReplicatedStorage to see whether it's name is on the AllowedRemotes table, but it deletes every remote inside of ReplicatedStorage. Any help?
local RStorage = game:GetService("ReplicatedStorage") local AllowedRemotes = { "DefaultServerSoundEvent", "AddCharacterLoadedEvent", "RemoveCharacterEvent", "SoundDispatcher", "OnNewMessage", "OnMessageDoneFiltering", "OnNewSystemMessage", "OnChannelJoined", "OnChannelLeft", "OnMuted", "OnUnmuted", "OnMainChannelSet", "ChannelNameColorUpdated", "SayMessageRequest", "SetBlockedUserIdsRequest" } while wait() do for _, v in pairs(RStorage:GetDescendants()) do if v:IsA('RemoteEvent') then if AllowedRemotes[v.Name] then -- do nothing else v:Destroy() end end end end
A table is built out of indexes… each index is a value. in your table, the value is a string containing the name of the remote that is allowed, but the index is still a number… there are 2 options, either you use custom keys for your table, or you go through the table to compare the value in it to the name
OPTION 1
local table = { key1 = "string 1", key2 = 2, key3 = 10 } print(table["key1"]) -- prints: string 1 print(table[0]) -- also print: string 1
OPTION 2
local table = { "string1", 2, 10 } for index,value in pairs in ipairs(table) do if value == "string 1" then print(table[index]) -- will print: string 1, is the same as printing value end end
to end this message, your updated script can be found below:
local RStorage = game:GetService("ReplicatedStorage") local Found = false local AllowedRemotes = { "RemoteEvent", "RemoteEvent1", "RemoteEvent2", "RemoteEvent3", "RemoteEvent4" } while wait() do for _,v in pairs(RStorage:GetDescendants()) do if v:IsA('RemoteEvent') then for index,value in ipairs(AllowedRemotes) do if v.Name == value then Found = true end end if Found == true then Found = false else v:Destroy() Found = false end end end end