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 assign a random BoolValue?

Basically I want this door to randomly chose a BoolValue (true or false)

Right now I have it changing by an if statement.

while true do
	wait(Config.Wait.Value)
	if Config.RandomKill.Value then
		if Config.Kill.Value then
			--Door.BrickColor = BrickColor.Random()
			Config.Kill.Value = false
		else
			--Door.BrickColor = BrickColor.Random()
			Config.Kill.Value = true -- I want this to randomly change it not by if statement
		end
	end
end

1 answer

Well what you can do is use math.Random() and if it is one number make it true and if it is another number make it false.

local bool=false
local n = math.random(1,2)
if n==1 then bool=true elseif n==2 then bool=false end

3 comments

0

You could also evaluate it with a relational operation: local b = math.random(2) == 1

0

BTW, add math.randomseed(tick()). Or else it wont be random

0

I would recommend putting it in tables, it makes things easier

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