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 make this code use math to calculate and make 2/3 of all players "bloxxers"?

im still a starter at scripting so I use tutorials but I can't find how to change the math on this script so it makes 2/3 of players in the game "bloxxers"

bloxxer = contestants [math.random(1, #contestants) ]

I just need help on how to make the math calculate 2/3 of players into "bloxxers"

1 comment

0

is this code from stickmasterluke?

2 answers

Really easy, to get the number of 2/3 of players, you can simply use

local numofbloxxers = (#game.Players:GetPlayers() / 3) --[[gets 1/3 of players]] * 2 --multiplies the number of 1/3 of players to get 2/3 of players.

Now, to make all ppl bloxxers, do this.

local bloxxers = {}

for i = 1, numofbloxxers do
table.insert(bloxxers, game.Players:GetPlayers()[i])
end

--do something with bloxxers table

Sorry that since I am on mobile, I cannot indent.

1 comment

0

Won't this add the same players over and over again?

This SHOULD work. Haven't tested. Don't call it the 'best' method. I'm not the 'best' scripter either.

local Bloxers = {}
local PlrNum = 0

for i, v (game.Players:GetChildren()) do    -- Loop through all objects where players are stored
	if v:IsA("Player") then                         -- Make sure object is a player
		PlrNum = PlrNum + 1                 -- Count players
	end
end

local BloxerCount = math.floor((PlrNum / 3) * 2)      -- Get bloxer ammount
local Count = 0

local A = game.Players:GetChildren()
while Count < BloxerCount do                                  -- Repeat for every bloxer needed
	local TempPlr = A[math.random(1, #A)]            -- Chose random player
	for i,v in ipairs(Bloxers) do
		if A ~= v then                                            -- Make sure player isn't allready a bloxer
			table.insert(Bloxers, A)                     -- Add player to list
			Count = Count + 1
		end
	end
end

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