Whenever I run this script, it doesn't work. It gives me an error of
attempt to index field ? (a nil value)
Here is the script that doesn't work:
local v = game.Workspace:GetChildren() for i =1, #v do if v[v].Name ~= "REPLACE WITH THIS" then v.KeycardDoor.ScriptedComponents["Door1"].RemoteOpen:InvokeServer() end end
Why does it not work? I don't understand.
Originally, I tried for i,v in pairs, but that didn't work. It didn't get every part of workspace, and I was trying to make it so it opens every model in workspace with that same name. But it didn't work. It didn't open every part of workspace like I wanted, only a few of them.
Other script that didn't work the way I wanted too.
for i,v in pairs(game.Workspace:GetChildren()) do if v.Name == "REPLACE WITH THIS" then if v:FindFirstChild("KeycardDoor") then v.KeycardDoor.ScriptedComponents["Door1"].RemoteOpen:InvokeServer() end end end