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

I can't seem to figure out why my math.random script is not working?

local module = require(script.Parent:WaitForChild("ModuleScript"))
local gui = game.StarterGui.ScreenGui.Clicks10


script.Parent.Activated:Connect(function()
	
	module.click1()
	
	script.Parent.Visible = false
	
local x = math.random(10)

if x == 1 then gui.a1.Visible = true else
	if x == 2 then gui.a2.Visible = true else
		if x == 3 then gui.a3.Visible = true else
			if x == 4 then gui.a4.Visible = true else
				if x == 5 then gui.a5.Visible = true else
					if x == 6 then gui.a6.Visible = true else
						if x == 7 then gui.a7.Visible = true else
							if x == 8 then gui.a8.Visible = true else
								if x == 9 then gui.a9.Visible = true else
									if x == 10 then gui.a10.Visible = true
end
end
end
end
end
end 
end 
end 
end
end 
end
end)

I'm trying to make one gui appear after clicking another, but I can't seem to make another one appear. the first one just disappears and a second one does not become visible. Any ideas?

2 comments

1

If you want to change the look of a gui in the middle of the game, use PlayerGui not StarterGui

1

I think you would have to use local x = math.random(0,10) --minimum value is 0 and max is 10.

1 answer

✓ Accepted answer

"I think you would have to use local x = math.random(0,10) --minimum value is 0 and max is 10."

SitaruDaniel is correct here.

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