I am trying to make a inventory system gui like All Star Tower Defense. The player’s units is already saved inside a Folder as a StringValue (Unit Name = StringValue Name). How can I make a Gui that displays the unit they own into a gui?
Well, in the other place that starts the game you could possibly check if the Player has Data, then implement conditional checks to enable what Towers to give from Towers the Player has currently equipped to change the Gui
Frames
Another way would be is to save your Data inside a Dictionary which would handle what Towers to equip, then load & check what Towers to give the Player:
local TowersToEquip = {
Tower1 = Player.leaderstats.Tower1.Value;
Tower2 = Player.leaderstats.Tower2.Value;
Tower3 = Player.leaderstats.Tower3.Value
}
Can you send me the Roblox Wiki page for Dictonary? I haven’t learned how to use that yet.
I think I understand what Dictionary is. But how can I implement this into the inventory system?
Well if the Inventory system you have set up are saved as StringValues
, you could just save & load them whenever you want inside a DataStore (Assuming you already have one), then detect what Towers the Player has or not
do something like this:
--(i made this on the post not in studio)
for i,v in pairs(unitFolder:GetChildren()) do
local frame = game.ReplicatedStorage.Frame:Clone() -- frame which displays unit (use viewport frames)
frame.Parent = inventoryGui -- inventory gui with all units (use grid constraint)
local viewportModel = v:Clone()
viewportModel.Parent = frame.Viewport
local camera = workspace.Camera:Clone()
camera.Parent = frame
-- (position camera however you want)
frame.ViewportFrame.CurrentCamera = camera
end
thats a simple way of doing it
Thank you! This helped alot I just tweaked a few things and now it works!
how it look like when it done?
I only gave a brief example on how you could implement it, the rest you’d need to figure out on your own
Are you talking abt the script or the how inventory gui?