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
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:
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)
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.
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