I’m trying to make a game where if a person has been in a room (touched the baseplate of the part basically) that it pops up a message on a screen saying that, that room has been checked.
Is there a way to do this locally and not using the Server for any event listening?
I got something like this:
local checkedRooms = {};
local roomChecked = Instance.new("BindableEvent");
local function onRoomChecked(roomName);
table.insert(checkedRooms, roomName);
end
roomChecked.Event:Connect(onRoomChecked);
How could I implement something like this to make it work on the local level?
I have about 30 rooms. How would you go about making an event listener for all the rooms instead of initializing every single one of them?
local room1 = blah blah blah1
local room2 = blah blah blah2
local room3 = blah blah blah3
local room4 = blah blah blah4
room1.Touched:Connect(function()
end)
room2.Touched:Connect(function()
end)
-- and so on
local rooms = workspace:WaitForChild("Rooms") --lets say this is a folder which contains the room floor parts
local roomTriggers = rooms:GetChildren() --create an array of the folders children
for _, trigger in ipairs(roomTriggers) do --iterate over the items of the array
trigger.Touched:Connect(function() --connect the same callback function to the touched event for each room
--do stuff
end)
end