Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why wont this script removing script work?[FIXED]

local workspace = game.Workspace
local script = script.Parent.Script

function deleteScript()
	if script.Parent == workspace.ScriptToDEVTEAM then
	wait(1)
	script.Parent = game.Lighting
	
	end
end

FIXED !! [changed to the following]

wait(3)
script:Destroy()

This was super easy !

1 comment

1

Going off of what Sporkyz said, "script" is a variable already defined in every script which refers to the script that the code was written in. Meaning you can completely get rid of line two.

2 answers

✓ Accepted answer
local workspace = game.Workspace
local script = script --only needs to be script

function deleteScript()
    if script.Parent == workspace.ScriptToDEVTEAM then
    wait(1)
    script.Parent:Destroy() --Destroy actually gets rid of the script.
    end
end

deleteScript() --you didn't call the function

lol you answered your own question before I was done typing so here you go.

Why would you want to make a self deleting script?

This discussion is preserved as it was. New answers, comments, and votes are closed.