I’m working on making a local script that functions to when you click a button, the menu disappears and a folder of quiz screens has quiz screens to be randomized in the script. I can’t get the quiz GUI to randomize. I’ve tried looking at videos but there aren’t many I can find.
local button = script.Parent
local QuizScreen1 = button.Parent.Parent.QuizScreens.QuizScreen
local QuizScreen2 = button.Parent.Parent.QuizScreens.QuizScreen2
local QuizScreens = {
QuizScreen1,
QuizScreen2
}
button.MouseButton1Click:Connect(function()
button.Parent.Parent.Enabled = false
local quiz = QuizScreens[math.random(1, #QuizScreens)]
quiz.Visible = true
end)
since you said that there is no error, you should try adding a print at the start of the buttonpress event. You should also add a print that print the quiz that is chosen. if you receive non of the prints, means there is something wrong with the event . if you receive both , that means there is something wrong with making the quiz visible. you can check the parent of the quiz and the visible value.by right quiz should not be nil
I see your issue. StarterGui is copied and sent to the player’s PlayerGui, so the player doesn’t get the update.
local button = script.Parent
local player = game.Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local QuizScreen1 = PlayerGui.OneQuiz:WaitForChild("QuizScreen1")
local QuizScreen2 = PlayerGui.TwoQuiz:WaitForChild("QuizScreen2")
local QuizScreens = {
QuizScreen1,
QuizScreen2
}
button.MouseButton1Click:Connect(function()
print("Clicked")
button.Parent.Visible = false
print("Main Menu Not There")
task.wait()
local quiz = QuizScreens[math.random(1, #QuizScreens)]
task.wait()
print("Randomized")
quiz.Visible = true
print("Visible")
end)