Help me make this visible

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Make it if its prints halloween, galaxy or christmas it becomes visible the next time you open Inventory

So I want it if you get the that certain thing you can see it the next time you open the inventory sample if like this

halloween.Visible = true

also that just a frame and you put that down below

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

and this is the other

if result == "halloween" then
	-- This would be visible the next time you open your inventory
	print("you got Halloween!")
elseif result == "christmas" then
	-- This would be visible the next time you open your inventory
	print("you got Christmas!")
elseif result == "galaxy" then
	-- This would be visible the next time you open your inventory
	print("you got Galaxy!")
end
1 Like

To achieve the desired functionality where certain items like “halloween,” “christmas,” or “galaxy” become visible in your inventory the next time you open it, you can use a combination of Roblox’s PlayerDataStore to save the acquired items and a script to update the visibility of the items in the inventory. Here’s a general outline of how you can do this:

  1. Save Acquired Items:
  • When a player acquires an item (e.g., “halloween,” “christmas,” or “galaxy”), save that information to their data store. You can use a service like PlayerDataStore to store this data.

luaCopy code

-- Assuming 'player' is the reference to the player who acquired the item
local key = "InventoryItems" -- The key to store the inventory data

-- Acquired item, e.g., when they click a button or something
local result = "halloween" -- Change this to the acquired item

-- Save the acquired item to the data store
player:SetAttribute(key, result)
  1. Load Inventory on Open:
  • When the inventory is opened (e.g., by clicking a button), load the player’s acquired items from the data store and update the visibility accordingly.

luaCopy code

local openInv = script.Parent.openInv -- Assuming you have a reference to the open inventory button
local SideInv = script.Parent.SideInv -- Replace with the actual frame references
local MainInv = script.Parent.MainInv
local detector = script.Parent.detector
local exitInv = script.Parent.exitInv

local key = "InventoryItems" -- The key to retrieve the inventory data

openInv.MouseButton1Click:Connect(function()
    -- Load the acquired item from the data store
    local acquiredItem = player:GetAttribute(key)

    if acquiredItem == "halloween" then
        -- Make the "halloween" item visible
        SideInv.Visible = true
        MainInv.Visible = true
        detector.Visible = true
        exitInv.Visible = true
    elseif acquiredItem == "christmas" then
        -- Make the "christmas" item visible
        -- (Similar code for other items)
    end
})

Make sure you replace the references to SideInv, MainInv, detector, and exitInv with the actual references to your inventory items. This code will ensure that when a player acquires an item, it becomes visible the next time they open their inventory.

2 Likes

it did work but if I use my own result local result = Skins[math.random(1,#Skins)]
it wont work cause I am using math.random to pick in this table

local Skins = {
“halloween”,
“christmas”,
“galaxy”
}

Any solutions?

local Skins = {
[1] = “halloween”,
[2] = “christmas”,
[3] = “galaxy”
}

2 Likes

It wont work. Any more solutions?

I made the math.random numbers it worked! But here on these part of the script
if acquiredItem == 1 then
– Make the “halloween” item visible
SideInv.Visible = true
MainInv.Visible = true
detector.Visible = true
exitInv.Visible = true
end

If i get 1 it gets visible when i clicked but when i try to get another number and its not a 1 its not visible anymore. Pls help