Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I get the system to count how many players and implement that in a function?

What can I add to the function to have the system count how many players there are and have that implement to the amount of gokarts set up. I have a feeling also, that one of my scripts might error since I made the dictionary to fit 15 cars but won't recognize them do to no Go kart# for not being there due to amount of players. I have the gameSpawns set up, I just need the amount of cars to spawn with the amount of players. Some how the system needs to count how many children of Players and implement with the cars in the storage which are named GoKart1, GoKart2, GoKart3, etc Tis is my goal for today and I couldnt figure it out

teleportGame = game.ServerScriptService.teleportGame
teleportLobby = game.ServerScriptService.teleportLobby



function enableTPgame()
wait(3)
teleportGame.Disabled = false
end


function disableTPgame()
wait(3)
teleportGame.Disabled = true
end

function tpCars() --tpcar function

end


enableTPgame()

wait(10)
tpCars()   --where car tp function will be
wait(10)

disableTPgame()

wait(1)

enableTPgame()



1 answer

plrs = game.Players.NumPlayers

for i = 1, plrs do
	--make your go-karts here
	kart.Name = "GoKart"..i
end

NumPlayers is actually a property of the Players thing. Alternatively you could use:GetChildren().

How you make your go-kart is up to you but you'll need a loop to make the right amount and if you want it to be named like you want.

This discussion is preserved as it was. New answers, comments, and votes are closed.