I need help Updating my UI using this script. So I want it to add a new UI frame every time something is added to the Inventory folder inside the player, but whenever a child is added to said folder you must leave and rejoin to update it.
I’ve tried adding a .ChildAdded function before the for statement, but then it doesn’t update the UI until a child is added to the folder. For instance, when I join the game, and a child is in the Inventory folder it doesn’t show the current children on the UI until a child is added.
All help is appreciated!
local plr = game.Players.LocalPlayer
local Inventory = plr:WaitForChild("Inventory")
local UIdesc = script.Parent.Parent.ItemInfo.Desc
local Name = script.Parent.Parent.ItemInfo.ToolName
for _, tool in pairs(Inventory:GetChildren()) do
local Btn = script.Parent.Parent.SwordButton:Clone()
Btn.Parent = script.Parent
Btn.Name = tool.Name
Btn.Visible = true
Btn.MouseButton1Click:Connect(function()
UIdesc.Text = tool.Desc.Value
Name.Text = tool.Name
end)
end