I am attempting to create a custom backpack system. It works when tools are added using clickdetectors, but not when a team’s tools are cloned when their character is created. The tools are added, but the gui is not. I have tried different wait times like .25, 1, 5 ect which work for me, but not always for others’ who test it. No errors are given. Any solutions?
Script that gives the tools:
local team1Tools = {"Cup", "Pistol", "Donut"} game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) -- wait(.25) works for me here, but not others local character = player.Character or player.CharacterAdded:Wait() for a,c in pairs(team1Tools) do local tool = game.ServerStorage:WaitForChild("Tools")[c]:Clone() tool.Parent = player.Backpack end end) end)
LocalScript that creates ui
local player = game.Players.LocalPlayer local backpack = player.Backpack local character = player.Character or player.CharacterAdded:Wait() local tools = {} local function tooladded(added) if added:IsA("Tool") then local new = true for i,v in pairs(tools) do if added == v then new = false end end if new == true then table.insert(tools, added) new = false local ui = player.PlayerGui:WaitForChild("Elements"):WaitForChild("ItemTemplate"):Clone() ui.Name = added.Name ui.Tool.Image = added.TextureId ui.Label.Text = #tools ui.Parent = player.PlayerGui:WaitForChild("MainGui"):WaitForChild("Backpack") end end end character.ChildAdded:Connect(tooladded) backpack.ChildAdded:Connect(tooladded)