Player.Backpack.ChildAdded:Connect(function(child)
if not (child:IsA("Tool")) then return end
if table.find(displayedItems, child) then return end
table.insert(displayedItems, child)
createItemFrame(child.Name, item)
end)
With
Player.Backpack.ChildAdded:Connect(function(child)
if not (child:IsA("Tool")) then return end
if table.find(displayedItems, child.Name) then return end
table.insert(displayedItems, child.Name)
createItemFrame(child.Name, child)
end)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local Player = Players.LocalPlayer
local RunService = game:GetService("RunService")
function createItemFrame(text, item)
local cloneItemFrame = ReplicatedStorage.Item:Clone()
cloneItemFrame.TextLabel.Text = text
cloneItemFrame.Tool.Value = item.Name
cloneItemFrame.ImageLabel.Image = item.TextureId
cloneItemFrame.Parent = Player.PlayerGui.Backpack.Frame;
cloneItemFrame.ImageButton.MouseButton1Down:Connect(function()
local tool = Player.Backpack:FindFirstChild(cloneItemFrame.Tool.Value)
local character = Player.Character or Player.Character:WaitForChild()
local humanoid = character.Humanoid;
local strokeFound = cloneItemFrame:FindFirstChild("UIStroke")
if strokeFound then
strokeFound:Destroy();
humanoid:UnequipTools()
return;
end
for i, frame in ipairs(Player.PlayerGui.Backpack.Frame:GetChildren()) do
for i, item in ipairs(frame:GetChildren()) do
if item.Name == "UIStroke" then
item:Destroy();
end
end
end
local stroke = Instance.new("UIStroke")
stroke.Color = Color3.fromRGB(255, 255, 255);
stroke.Parent = cloneItemFrame;
stroke.Thickness = 2.1
task.wait(0.10)
humanoid:EquipTool(tool)
end)
end
-- Create item frames for the tools which are replicated from starter pack
for i, item in ipairs(Player.Backpack:GetChildren()) do
createItemFrame(tostring(i), item)
end
-- Create item frames every time a NEW item is added to backpack
local displayedItems = {}
Player.Backpack.ChildAdded:Connect(function(child)
if not (child:IsA("Tool")) then return end
if table.find(displayedItems, child.Name) then return end
table.insert(displayedItems, child.Name)
createItemFrame(child.Name, child)
end)
local KeyCodes = {
[49] = 1,
[50] = 2,
[51] = 3,
[52] = 4,
[53] = 5,
[54] = 6,
[55] = 7
}
UserInputService.InputBegan:Connect(function(input: InputObject)
for i, item in ipairs(Player.PlayerGui.Backpack.Frame:GetChildren()) do
if item:IsA("Frame") then
for i, child in ipairs(item:GetChildren()) do
if child:IsA("TextLabel") then
if KeyCodes[input.KeyCode.Value] == tonumber(child.Text) then
local tool = Player.Backpack:FindFirstChild(item.Tool.Value)
local character = Player.Character or Player.Character:WaitForChild()
local humanoid = character.Humanoid;
local strokeFound = item:FindFirstChild("UIStroke")
if strokeFound then
strokeFound:Destroy();
humanoid:UnequipTools()
return;
end
for i, frame in ipairs(Player.PlayerGui.Backpack.Frame:GetChildren()) do
for i, item in ipairs(frame:GetChildren()) do
if item.Name == "UIStroke" then
item:Destroy();
end
end
end
local stroke = Instance.new("UIStroke")
stroke.Color = Color3.fromRGB(255, 255, 255);
stroke.Parent = item;
stroke.Thickness = 2.1
task.wait(0.10)
humanoid:EquipTool(tool)
end
end
end
end
end
end)
-- Create item frames for the tools which are replicated from starter pack
for i, item in ipairs(Player.Backpack:GetChildren()) do
createItemFrame(tostring(i), item)
end
-- Create item frames every time a NEW item is added to backpack
local displayedItems = {}
Player.Backpack.ChildAdded:Connect(function(child)
if not (child:IsA("Tool")) then return end
if table.find(displayedItems, child) then return end
table.insert(displayedItems, child)
createItemFrame(child.Name, item)
end)
with
local displayedItems = {}
-- Create item frames for the tools which are replicated from starter pack
for i, item in ipairs(Player.Backpack:GetChildren()) do
createItemFrame(tostring(i), item)
table.insert(displayedItems, child)
end
-- Create item frames every time a NEW item is added to backpack
Player.Backpack.ChildAdded:Connect(function(child)
if not (child:IsA("Tool")) then return end
if table.find(displayedItems, child) then return end
table.insert(displayedItems, child)
createItemFrame(child.Name, item)
end)
thats my bad, getting hard to track the messages now haha
local displayedItems = {}
-- Create item frames for the tools which are replicated from starter pack
for i, item in ipairs(Player.Backpack:GetChildren()) do
createItemFrame(tostring(i), item)
table.insert(displayedItems, item.Name)
end
-- Create item frames every time a NEW item is added to backpack
Player.Backpack.ChildAdded:Connect(function(child)
if not (child:IsA("Tool")) then return end
if table.find(displayedItems, child) then return end
table.insert(displayedItems, child)
createItemFrame(child.Name, child)
end)
local displayedItems = {}
-- Create item frames for the tools which are replicated from starter pack
for i, item in ipairs(Player.Backpack:GetChildren()) do
createItemFrame(tostring(i), item)
table.insert(displayedItems, item.Name)
end
-- Create item frames every time a NEW item is added to backpack
Player.Backpack.ChildAdded:Connect(function(child)
if not (child:IsA("Tool")) then return end
if table.find(displayedItems, child.Name) then return end
table.insert(displayedItems, child.Name)
createItemFrame(child.Name, child)
end)