Hi,
What you have done is made it so it chooses the random number once but never again. Plus I also suggest adding a debounce (or DB) to prevent players spam clicking and risk breaking your game/project.
If i have understood what you are after correctly, you need the code to be as follows:
local DB = false
script.Parent.Picture1.Visible = false
script.Parent.Picture2.Visible = false
script.Parent.Picture3.Visible = false
script.Parent.TextButton.Visible = true
script.Parent.TextButton.MouseButton1Click:Connect(function()
if DB == false then
DB = true
local random = math.random(1,3)
script.Parent.TextButton.Visible = false
if random == 1 then
script.Parent.Picture1.Visible = true
print(1)
elseif random == 2 then
script.Parent.Picture2.Visible = true
print(2)
elseif random == 3 then
script.Parent.Picture3.Visible = true
print(3)
end
wait(2)
script.Parent.Picture1.Visible = false
script.Parent.Picture2.Visible = false
script.Parent.Picture3.Visible = false
script.Parent.TextButton.Visible = true
DB= false
end)
Hope this helps, any other queries, don't hesitate to ask. :)
Note: I sometimes call scripts "code", it means the same thing
1 comment
Remember to click accept answer so that the website knows it is solved