Is there a way to check if a script is already running on a object in the workspace

Hi I was wondering if there is anyway possible how to test if a script is already running on a particular assets in the workspace.

You need to define running. My definition say that as long as the script isn’t disabled it’s “running”.

1 Like

Uh, no, not really. All scripts that aren’t disabled are running.

1 Like

Would you mind clearing up what exactly you mean by “Running on a object in the workspace” If you are looking for if a script is running the best you can do is find the script and check if it is “Disabled” or not. If it is then it’s not running if it’s not then it either is running or has hit an error in which case you can use the Output tool to see the error and then attempt to debug the error.

Not sure if this is what you are looking for however I suggest being more specific.

If you mean to check whether a script is already “operating” on an instance in workspace, it’s usually best to avoid situations like this altogether and only letting one script take responsibility, editing it if you don’t like its behavior.

But, if you absolutely need to check whether an object is being used by a script, you can create a BoolValue under the object that is checked whenever the object needs to be used.

local part = --Part in workspace

if part.BoolValue.Value == false then
    part.BoolValue.Value = true
    --do your thing
    part.BoolValue.Value = false

Keep in mind that this structure can be a lot more freeform, you could put the BoolValue in a Storage service and let other scripts check it there, and you can do this on local or server scripts, but not both.

Thanks this will work for what i want

1 Like