Math.Random Help!

Hey!

i need a script, remember there 3 button (Button1,Button2,Button3) in the map, when someone clicked the button1 it will be transparent to 1 and random change to other button(RANDOM 2 AND 3)(tranparent 0) position, if no one click button1 (60 second) it will transparent 1 and change other button(RANDOM 2 AND 3) position

just like the piggy game key random spawn position

If you don’t understand here the video, the video below

I already try it it doesn’t work

someone already make the code but it doesn’t work

Make a workspace folder, place script and 3 parts in the folder. Make a clickdetector for each part that what he said

local buttonFolder = script.Parent

local button1 = buttonFolder.Button1
local button2 = buttonFolder.Button2
local button3 = buttonFolder.Button3

local function getRandomButton()
local randomNumber = math.random(1, 3)

if randomNumber == 1 then
    return button1
elseif randomNumber == 2 then
    return button2
else
    return button3
end

end

local function onClicked(button)
button.Transparency = 1

local nextButton = getRandomButton()
while nextButton.Transparency == 1 do
    nextButton = getRandomButton()
end

nextButton.Transparency = 0

end

local function onButtonClicked()
local clickedButton = script.Parent
onClicked(clickedButton)
end

button1.ClickDetector.MouseClick:Connect(onButtonClicked)
button2.ClickDetector.MouseClick:Connect(onButtonClicked)
button3.ClickDetector.MouseClick:Connect(onButtonClicked)