script two:
local plr = game.Players.LocalPlayer
local char=plr.Character
local amountoftools=char.AmountOfTools
local maxtools=char.MaxTools
local gui=script.Parent
local backpacks=gui.Backpack
local remotes=gui.Remotes
local toolthere=gui.ToolsThere
local tweenservice=game:GetService("TweenService")
local inputsevice=game:GetService("UserInputService")
-------------------------------------------------------------------
local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
-------------------------------------------------------------------
local function ItemLoader(tool)
local GuiTool=script.Tool:Clone()
GuiTool.Parent=backpacks.Items
GuiTool.ToolName.Text=tool.Name
if tool.TextureId ~= nil then
GuiTool.Icon.Image=tool.TextureId
end
remotes.ToolAddUnAdd:FireServer(true,tool)
toolthere.Value+=1
GuiTool.Count.Value=toolthere.Value
GuiTool.Name=tool.Name
GuiTool.ToolId.Value=tool.ID.Value
end
for i,v in pairs(plr.Backpack:GetChildren()) do
if v:IsA("Tool") then
ItemLoader(v)
end
end
plr.Backpack.DescendantAdded:Connect(function(tool)
if tool:IsA("Tool") then
ItemLoader(tool)
end
end)
plr.Backpack.DescendantRemoving:Connect(function(tool)
if tool:IsA("Tool") then
remotes.ToolAddUnAdd:FireServer(false,tool)
toolthere.Value-=1
for i,v in pairs(backpacks.Items:GetChildren()) do
if v:IsA("Frame") then
if v.ToolId.Value==tool.ID.Value then
v:Destroy()
end
end
end
end
end)
amountoftools.Changed:Connect(function()
local scale=amountoftools.Value/maxtools.Value
tweenservice:Create(gui.Backpack.Amount.bar,TweenInfo.new(1,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out),{Size = UDim2.new(scale,0,1,0) }):Play()
end)