Hello. I am having an issue with this script, where I am trying to replace every DoorScript, using the command bar, in the workspace with a new one. However, my stupid self made all the doors in different structures, so the only common item the doors have is the ‘ANOMALYDETECTOR’ part. So, I used that to find all scripts. However, this is not working.
The only door with the new script is SCAPEGOAT.
If something like this has been posted, please direct me towards it.
Thank you!
for i, v in pairs(game.Workspace:GetDescendants()) do
if v:IsA("Part") and v.Name == "ANOMALYDETECTOR" then
v.Parent.ProximityPrompt.Script:Destroy()
local moom = game.Workspace.SCAPEGOAT.Model.Button.ProximityPrompt.DoorScript:Clone()
moom.Parent = v.Parent.ProximityPrompt
end
end
do all the ProximityPrompts have the same ActionText if so you can do something like this
for i, descendant in ipairs(game.Workspace:GetDescendants()) do
-- if descendant is not a proximity prompt skip this descendant
if descendant:IsA("ProximityPrompt") == false then continue end
-- if the ActionText is not correct then skip this descendant
if descendant.ActionText ~= "OPEN DOOR" then continue end
-- destroy the old script
descendant.Script:Destroy()
-- clone the new script
game.ReplicatedStorage.NewScript:Clone().Parent = descendant
end
but i would not recommend doing this as you will always run into the same problem every time you want to change the script instead what you should do is give all the doors a tag
They do not, as there are two different kinds of doors.
Is there anything wrong with my script? Or am I not using command bar properly.
I’ll consider tagging later.