Hey, im trying to get a script which will make 1 of 3 frames visible with math.random, which works, but what doesnt work is trying to make the previous frame unvisible
local plr = game.Players.LocalPlayer
local GameGUI = plr.PlayerGui:WaitForChild("GameGUI")
local UIS = game:GetService("UserInputService")
local Mineables = GameGUI.Background:GetChildren()
print(Mineables)
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
local n = math.random(1,3)
for i,v in Mineables do
if n == i then
print(Mineables[i])
Mineables[i].Visible = true
end
end
end
end)
Maybe add a variable for the chosen frame and using that, hide the frame:
local plr = game.Players.LocalPlayer
local GameGUI = plr.PlayerGui:WaitForChild("GameGUI")
local UIS = game:GetService("UserInputService")
local Mineables = GameGUI.Background:GetChildren()
print(Mineables)
local previousframe
UIS.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if previousframe then
previousframe.Visible = false
previousframe = nil
end
local n = math.random(1,3)
for i,v in Mineables do
if n == i then
print(Mineables[i])
Mineables[i].Visible = true
previousframe = Mineables[i]
end
end
end
end)