Main script (GameManager) with Knit?

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.

Thanks for any input on this =)

5 Likes

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?

Thanks for the response

1 Like

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?

1 Like

To be honest, I don’t really see the point of delaying services from starting. Can you give a little more detail on why you need to do so?

if #game.Players:GetPlayers() < 6 then return end
Try running something like this every time a player joins before running the Knit service.

1 Like

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 :thinking:

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

1 Like

Huh, that’s very interesting. And then will the components load automatically when the condition is met or I will have to load them manually? :thinking:

Yup, the component will automatically be constructed when the condition is met.

1 Like

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 :stuck_out_tongue:

Thanks again!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.