Script to disable an item with a certain name

I notice that this thing named ‘SystemWeld’ keeps appearing out of no where, and I want it to be disabled if it has the name ‘SystemWeld’. How do I do that with a script?

workspace.DescendantAdded:Connect(function(desc)
    if desc.Name == "SystemWeld" then
        desc.Enabled = false
    end
end)

where would i put that script in?

Definitely a server script because they load faster in the game, but if you need to do this locally, then use an update function and connect descendantAdded to that

does it work for every category? workspace, players, camera, etc?

it sure does, but only for items added in the workspace, but that should be totally fine for what your doing.

so if it’s in other places, add another section like this?

workspace.DescendantAdded:Connect(function(desc)
if desc.Name == “SystemWeld” then
desc.Enabled = false
end
end)
Players.DescendantAdded:Connect(function(desc)
if desc.Name == “SystemWeld” then
desc.Enabled = false
end
end)
Lighting.DescendantAdded:Connect(function(desc)
if desc.Name == “SystemWeld” then
desc.Enabled = false
end
end)

Yep!
that will do it
characters=30

it doesn’t work ;/

characters = 30

there is no reason for it not to work other than the name of the weld is mispelled, or it didn’t load in yet. In the case that it didnt load in, use the update function i was talking about:

local listOfPlacesToCheck = {workspace, game:GetService("Lighting")}

local function updateWeldDisabled()
    for _, s in pairs(listOfPlacesToCheck) do
        for _, v in pairs(s:GetDescendants()) do
            if v.Name == "SystemWeld" then
                v.Enabled = false
            end
        end
    end
end

updateWeldDisabled()

for _, s in pairs(listOfPlacesToCheck) do
    s.DescendantAdded:Connect(updateWeldDisabled)
end)

-- it would probably be better in your case if you did the last thing like this however for performance reasons:
for _, s in pairs(listOfPlacesToCheck) do
    s.DescendantAdded:Connect(function(desc)
        if desc.Name == "SystemWeld" then
            desc.Enabled = false
        end
    end)
end)

this still goes in??? chars 30

@Moonvane
workspace. only applies to the Workspace.

game.DescendantAdded:Connect(function(desc)
    if desc.Name == "SystemWeld" then
        desc.Enabled = false
    end
end)

This, however, searches the whole game.
It’d be useful to know where the instance spawns, but you could also use

local SystemWeld = game:WaitForChild("SystemWeld")
SysyemWeld:Destroy()

It’s not

script.Enabled = false

but rather

script.Disabled = true

local script or normal? chars 30

@gxenious
Yes, but you need to put a pcall because some things don’t give you permission to check them:
image

Server (normal) Script, not LocalScript

This whole comment is incorrect.
You don’t use server scripts just because they “load faster”, that is completely dependant on the game’s mechanics and graphics.

Your entire comment is incorrect, local scripts load in based on a player joining and where they are, server scripts load in before any players join, as soon as the game starts. This is why .PlayerAdded 100% of the time fires in server scripts when placed properly.

@1BL1ZZARD
I’d recommend one of my suggestions:

These can both be put into Server Scripts

To fix your second comment:

local SystemWeld = game:WaitForChild("SystemWeld")
SysyemWeld:Destroy()

Did you mean to use workspace:WaitForChild(“SystemWeld”) ?
This will never work.

And to fix your first comment:

game.DescendantAdded:Connect(function(desc)
    pcall(function()
        if desc.Name == "SystemWeld" then
            desc.Enabled = false
        end
    end)
end)

Like what I said earlier, it will error saying “Lacking permission” if you attempt to check some items, such as the CorePackages.