Trying to create something for my own game but also make it available for others in CC. I want to make it smart depending on if a game component exists or not.
Here is the scenario. I have the following code. It will detect for 3 players before starting the round...
local gameState = "LOBBY" print("Waiting for 2 players to join...") function OnRoundStart() gameState = "PLAYING" print("New round starting...") Events.BroadcastToAllPlayers("placeHealthBarsOnce", placeHealthBarsOnce) end Game.roundStartEvent:Connect(OnRoundStart) function Tick() if gameState == "LOBBY" then -- The condition for starting a round local playerCount = #Game.GetPlayers() if playerCount >= 3 then Game.StartRound() end end end
However, in my game I already have the "Lobby Required Players" component where you can set the required players count. IF that component is present I would like to get the required players number from the customer properties of the component called RequiredPlayers. If not, then I will just use the hand coded number.
Is there a way to look for the component and getting the RequiredPlayers number without having to add the component to the custom properties of my script?
Here is a quick video for a more detailed explanation if the writing above did not share the goal well.
As always, thanks for the help!