Once the door will open, a polling function will start detecting nearby players. You need to create invisible, anchored and non-collidable part that will cover the floor area where you want to have door opened triggered. In this system polling is only done after “doors” have opened, and for each door separately. Long story short, I use hybrid system of polling and Touched events. There are however issues with ToucheEnded event, that I will not indulge in right now. If you have lots of doors and players, it will reduce significantly workload on the server. That is why I have suggested Touched event. Introduce similar scripts for other parts of your world, and the whole thing will eventually break apart. But in larger games, with lots of players and doors you may start to notice lag. If that is your only polling script in the game, you may get away with it. Polling however has a huge impact on performance, especially if you connect it to run service or use short intervals between polls (like wait() which is approx. For example I use it as anti-teleport exploit and anti speed hacks. In Roblox it is usually used to sample character position, as player movements cannot be easily predicted. Polling means synchronous sampling of certain values. Once the door is opened, simple periodic magnitude check on all players is usually best method to close the doors.įirst of all sorry for late reply. I would use Touched event on special invisible activation plate to open the doors. You should avoid polling whenever you can. That being said this method is quite inefficient. If player:DistanceFromCharacter() 0 thenĮlseif PreviousOpenDoors and chars = 0 then coroutine.wrap(function()įor _, player in pairs(Players:GetPlayers()) doįor _, door in pairs(CollectionService:GetTagged('Doors')) do Since you are already polling through all the players, all you need to do is to remember how many characters are near that door, and only close them when the said number equals zero.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |