So i have game.Workspace.StaffDoor but when I type S nothing shows up, so I though, Okay then lets do game.Workspace:FindFirstChild("StaffDoor") I tested it an the script didn't work the way it did in the other game I created with less parts. Is there a way to fix this?
COMMUNITY QUESTION
My script is ignoring parts in workspace?
1 answer
You should explain in more detail what you mean in future questions:
- What does typing "S" do? How?
- What do you mean by "less parts"?
- What do you mean "nothing shows up" - are you trying to print something, is a gui supposed to show up, what?
I'm guessing that your problem is that you have multiple StaffDoors and your script is only set up to work with one. If my guess is correct, you'll need to iterate over all the workspace's children, rather than use FindFirstChild (which only finds the "first child", as the name suggests).
--Instead of:
function OnTouch(part)
-- function contents here
end
workspace.StaffDoor.Touched:Connect(OnTouch)
--You need:
function OnTouch(door, part)
--use 'door' instead of 'workspace.StaffDoor'; otherwise, function contents may be the same
end
local ch = workspace:GetChildren()
local door
for i = 1, #ch do
door = ch[i]
door.Touched:Connect(function(part) OnTouch(door, part) end)
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Please give us the full script
Please explain it more. What is the script supposed to do? What is it doing? and if it's possible paste your script here
Probably an Only Door for staffs...