Get Certain Amount of Players

I’m trying to make a type of minigame, where a certain amount of players get teleported to one side, and the other teleported to the other side.

It can be from one 10%, 25% or 50% of the max player count.

My main issue is how to get the percentage of players to be teleported.

If you need me to explain more of what I want, you’re more than welcome to!
Any help is appreciated!

1 Like

I think you can just use * 0.1 means 10% or * 0.25 means 25%

1 Like

This is what I have, I don’t know if it will work yet because I haven’t tested yet.

function SeperatePlayers()
	
	local AllPlayers = Players:GetPlayers()
	local TenPercentPlayers = AllPlayers * 0.1
	
	-- Teleport 10% in one spot, the other 90% in another
	
end

How would I teleport 10% in one spot, and the other 90% to another spot?

Side note, would this make it random, because I want this to be random.

oh you want to do that with players make sure to use math.round then

don’t know about random though

How would I use math.round, I’ve never used that before.

just use divsion and like use fraction to get a “percentage”

function SeperatePlayers()
	
	local AllPlayers = Players:GetPlayers()
	local TenPercentPlayers = AllPlayers / 10
	
	-- Teleport 10% in one spot, the other 90% in another
	
end

Something like this?

Also, if there was a random amount of people, like 14 people for example, wouldn’t that be 1.4 people, which is impossible. Or would math.round help with that?

I’m still stuck on how to teleport them though.

Though this isn’t a great way of doing it, you could just choose the team by randomize and then send people on each teams and stop sending to the other teams once it knows it has 10 people in it.

Although that would work, that isn’t really my goal. I want 10% of the total players in the server to one side, and teleport the other 90% to the other side.

But mine would be safer from bugs as how you stated on how it would be 1.4 if it were to be 14 players and so math.round wouldn’t fix that as 1.4 would round to 1. I think, math.floor might help something with that issue.

I just got it, thank you to everyone who tried to help!

1 Like

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