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

Making a script, that deletes other scripts?

Asked by 6 years ago
Edited 6 years ago

I'm trying to make a script to delete a bunch of other scripts inside parts called "AntiUnlock" Here is my script I put into command bar, it just turns black.

local anti = workspace:FindFirstAncestor("AntiUnlock")
if anti then
    anti:Destroy()
end

For more information here it is: I've tried using :FindFirstChild and it does the same thing. When I execute it into command bar the whole thing doesn't run, it just turns black. I've tried :FindFirstDescendant(), unfortunately that isn't a real thing.

0
Please elaborate more, then I may be able to assist you. uhTeddy 101 — 6y
0
The workspace has no ancestor, except the game.. The correct code, I assume is FindFirstDescendant. UgOsMiLy 1074 — 6y

2 answers

Log in to vote
0
Answered by
JellyYn 70
6 years ago
Edited 6 years ago

You are using :FindFirstAncestor() You should use :FindFirstDescendant(), since, like @UgOsMiLy commented, Workspace has no ancestor except for game. The correct script should be

local anti = workspace:FindFirstDescendant("AntiUnlock")
if anti then
    anti:Destroy()
end

If this doesn't work, try :FindFirstChild()

0
:FindFirstDescendant() isn't part of workspace it wont work, also FindFirstChild isn't going to work. OfficialMiles 0 — 6y
0
Could you just do workspace.AntiUnlock? if there is no others ofc JellyYn 70 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

If something's wrong, Leave a comment :)

local anti = workspace:GetChildren()
for i=1 , #anti do
if anti[i] ==  "AntiUnlock" then --Try if anti[i].Name ==  "AntiUnlock" then
    anti[i]:Destroy()
end
end
0
I'm sure the script works, but in the command bar it just turns black and doesn't run. OfficialMiles 0 — 6y

Answer this question