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

math.random() doesn't work past 2 in 1 - 10? pls gimme help

so apparently math.random() does not work above the number 2. Here is my script:

script.Parent.ClickDetector.MouseClick:Connect(function(henlo)
	script.Parent.Sound:Play()
	for i = 0, 1, 0.09 do
		wait(i/50)
		script.Parent.CFrame = script.Parent.CFrame:Lerp(script.Parent.Parent.Button1.CFrame, i)
	end
	local e = math.random(1, 10)
	if e == 1 then
		print("Method: GET CRUSHED BY A WEIGHTED COMPANION CUBE")
		workspace.CompCube.Anchored = false
	end
	if e == 2 then
		print("Method: GET CRUSHED BY A HEAVY DUTY CRUSHER")
		workspace.crosher:Play()
		for z = 0, 1, 0.1 do
		wait(z/50)
		workspace.Crusher.CFrame = workspace.Crusher.CFrame:Lerp(workspace.Crusher.Crusher1.CFrame, z)
	end
	if e == 3 then
		workspace:ClearAllChildren()
	end
	if e == 4 then
		workspace:ClearAllChildren()
	end
	if e == 5 then
		workspace:ClearAllChildren()
	end
	if e == 6 then
		workspace:ClearAllChildren()
	end
	if e == 7 then
		workspace:ClearAllChildren()
	end
	if e == 8 then
		workspace:ClearAllChildren()
	end
	if e == 9 then
		workspace:ClearAllChildren()
	end
	if e == 10 then
		workspace:ClearAllChildren()
	end
	end
end)

It doesn't work at all past the number two for me, I've ran numerous tests, but it just won't work?

2 comments

0

btw I have tried different numbers other than 1 - 10, still doesn't work.

0

Btw there's also no output error

1 answer

That is because you can’t use clear all children for workspace. Just to test I recommend your function to print(e). Do that for every if statement except 1 and 2. Hope it helps!

7 comments

0

Sadly it's still broken, ty for your time though.

0

Alright, I will try to find a fix.

0

Try to print E before the checks.

0

Still doesn't work, sorry lol... It just prints a bunch of the previous numbers that happened like 1 and 2

0

lol

0

I saw another thread that this was happening to another guy. Is math.random() supposed to even pick more than two answers? I am going to face palm if math.random() can't choose more than two results!!!!

0

Could you aleast upvote or accept my answer?

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