I was making this anti-exploit script and it's supposed to delete all of Workspaces's children. Why doesnt it work? This is the script
--[[{{{(((^<<<THIS SCRIPT CHECKS IF THE BRICK CLEANUP SCRIPT WORKS, IF YOU HEAR A LOUD SIREN, SOMEONE HAS EXPLOITED IF YOU DO NOT WANT THIS SCRIPT IN THIS TOOL, PLEASE DISABLE IT >>>^)))}}]]-- local h = Instance.new ("Hint") h.Parent = game.Workspace h.Text = "ANTI-EXPLOIT/ANTI-SPAM v0.8 BY xXxCONBOY456xXx" local EXPLOIT = script.Sound if script.Parent.Parent ~= nil then wait(26) if script.Parent.Parent ~= nil then EXPLOIT:play() wait(100) if script.Parent.Parent ~= nil then script.Parent.Parent.Parent.GetChildren:Destroy() elseif script.Parent.Parent ==nil then return end end end
You're using GetChildren() wrong. GetChildren() is a method, which means to use it you must use :
. On top of that, it returns a table. You can only use the Destroy() method on an Instance. To destroy all of workspace's children with GetChildren(), we must use a for
loop.
for index,value in pairs(Workspace:GetChildren()) do value:Destroy() end
This should work, but it would be much cleaner to use ClearAllChildren().
Workspace:ClearAllChildren()
Hope I helped!