Hi! I was wondering how one would go about having a Knit service that is a GameManager which would be the one to decide when stuff get started and what not…
For example, I want to make a GameManager service that starts with a LobbyService at first and then when we have enough players the GameManager starts all other needed services for the game or any other way to achieve this.
Do you think I could do something like in the Knit:Init function of the scripts that need the game to start I wait until my GameManager.State == Started or something like that?
On a certain service, KnitInit, why not just yield until a certain number of players have been met. But I don’t really recommend this approach, because what if a player wants to use a certain service?
I’m making a coop game where I need 12 players to start a game and until then I wouldve liked the players to be able to wander around the island without being able to interact with my Knit Components placed around the island… I guess I could just make a lobby spot where players are stuck there until we have enough players
Hmm, if it is only for components you can just add a ShouldExtend Extension to your component.
For example:
--In a module script
local Players = game:GetService("Players");
local MINIMUM_PLAYERS = 12;
local EnoughPlayers = {};
function EnoughPlayers.ShouldConstruct(component)
return #Players:GetPlayers() >= MINIMUM_PLAYERS;
end
return EnoughPlayers;
Then for each component that you don’t want the players to interact with just require this module and put it in the Extensions table
Dang okay nice thank you I will try to use that and if it doesn’t meet 100% of what I want to do i’ll pro end up make a small lobby zone where players wait at the beginning so that they can’t interact with the stuff in the map