This script is supposed to check Workspace for newly inserted objects, see if those objects are within the parameters of an array, and to check if that newly created object is a player's character, if not either of those things, to remove it.
However, regardless of whether or not that object is within the parameters of the array, the script still deletes it.
Can someone please help?
Here's the script:
local allowed = {"Handle", "Bullet", "Rocket", "Camera", "Bomb", "Explosion", "Humanoid", "Part", "Missile", "Grenade", "Flashbang"} workspace.ChildAdded:connect(function(item) Check(item) end) function Check(item) for i,v in pairs(allowed) do if v[i] == item.Name or item:FindFirstChild("Humanoid") then print('good') else item:Destroy() end end end
The reason it wasn't working is because you are checking the entire table and deleting it if it returns false (I insert a humanoid, everything in the table except for humanoid will delete it)
The solution would be to add a boolean to it
local allowed = {"Handle", "Bullet", "Rocket", "Camera", "Bomb", "Explosion", "Humanoid", "Part", "Missile", "Grenade", "Flashbang"} local checked = false workspace.ChildAdded:connect(function(item) Check(item) end) function Check(item) for _,v in pairs(allowed) do if v == item.Name or item:FindFirstChild("Humanoid") then checked = true end end if not checked then wait() item:Destroy() end checked = false end