I found the solution dont comment on this anymore to avoid spam

does anyone have answers for this?

I want an inventory where if you do math.random(1,5) and shows up a 1 it would make a frame pop up if you click something unlike before where it doesnt pop up.
But my problem is if I get a 1 and do math.random again it doesnt pop up anymore

code

local key = “InventoryItems” – The key to store the inventory data

crate1.MouseButton1Click:Connect(function()
local get = math.random(1,5)

print(get)

player:SetAttribute(key, get)	

end)

openInv.MouseButton1Click:Connect(function()

local acquiredItem = player:GetAttribute(key)

MainInv.Visible = true
detector.Visible = true
exitInv.Visible = true
if acquiredItem == 1 then
    SideInv.Visible = true
    MainInv.Visible = true
    detector.Visible = true
    exitInv.Visible = true
end

end)

5 Likes

SideInv, MainInv, detector, and exitInv are already visible when 1 comes up again. At least as far as the code you’ve shared shows, nothing is hiding those four things for the next time math.random() returns 1.

Hard to make sense of what you are doing here … Both in explanation and code provide.

i forgot to show this

exitInv.MouseButton1Click:Connect(function()
SideInv.Visible = false
MainInv.Visible = false
detector.Visible = false
exitInv.Visible = false
end)

1 Like

I tried to make it short as possible but what I am trying to achieve is if you get a 1 from math.random it shows up the next time you click something. But the error is if i try to run math.random again and you get a number besides 1 it doesnt show up anymore even if you got 1 earlier.

1 Like

What isn’t showing up? A Gui? Are you clicking on a loot box?

Fames, TextBox, TextButton, ImageLabel, TextLabel … All have A ZIndex …
Set Zindex of whatever 1 is to be showing to highest. (ZIndex is a property)
With the highest ZIndex it will always be on top of others.

the sideinv. Its a frame (dont mind this)

1 Like

it has the hightest zindex. I think the problem is the 1 in math.random doesnt save ill show you a video

1 Like

So is it there and covered or noting happens?
use </> option in post to show the code used.

I fixed it! Dont comment on this anymore to avoid spam pls.

1 Like