I'm creating a custom inventory, called cauldron, and in the cauldron I have potions. The number of different potions a player has depends on their level, called Power. If they are Power 5, they have access to potions 1-5. I have this scrolling frame, and am trying to make it so that when the player opens the cauldron GUI, they see all of their potions there. So far I have a script that loops through based on the players Power.
I'm having an issue where I don't know how to make it so this GUI is only updated when needed. So far it will keep cloning the frames every time I click to open the GUI. Should I make this happen when the player first connects to the server, and then only update it when the reach a new Power level?
Also, should I be using a remote for this? I know I will have a remote for enabling the actual potion to be used by the player.
--When player clicks button, actual cauldron inventory pops up (CauldronScrollFrame)
cauldronOuterFrame = script.Parent.Parent.Parent:FindFirstChild("CauldronOuterFrame")
cauldronSideBtn = script.Parent
--get indiviual ptn frame that will be cloned
local template = script.Parent.Parent.Parent:WaitForChild("CauldronOuterFrame"):WaitForChild("CauldronScrollFrame")
:WaitForChild("Spell1")
print (template.Name)
function onClick()
--duplicate ptnFrame for every ptn based on Power
--get player's Power lvl to determine what ptns will be visible on cauldronFrame
local plrPower = game.Players.LocalPlayer.leaderstats.Power.value
for i = 2, plrPower do --i = 2 because you start with lvl1ptn, which is included in the total Power
local new = template:Clone()
new.Name = "Spell"..i
new.Parent = template.Parent
end
--print "CaulSideBtn clicked, opening scrollFrame gui..."
if cauldronOuterFrame.Visible == false then
cauldronOuterFrame.Visible = true
--print "Frame made visible"
elseif cauldronOuterFrame.Visible == true then
cauldronOuterFrame.Visible = false
--print "Frame made invisible"
end
end
cauldronSideBtn.MouseButton1Click:Connect(onClick)
