Alright, so rn I have Tools or Items in my Inventory as a Textbutton and I want to change that to a Image Button and I tried getting help from chat GPT but…Anyways I put the Image Label in the TextButton cuz I tried using only the Image Button but it didn’t work that’s why I put the label in the text button and I want for each Tool their Image to be seen and I want it to be like f. e. Invisible which is a tool to be like Inisible = id and then the id for that button does that work cuz I have no idea how to do that( and the Invisible Tool is not the only Tool )
InventoryLocalScript:
local InventoryEvent = game.ReplicatedStorage.Remotes.InventoryEvent
local itemFrame = script.Parent:FindFirstChild("ItemsFrame")
InventoryEvent.OnClientEvent:Connect(function(ItemName, Value)
if Value == true then
local ItemButton = script.Parent.ItemsFrame.ItemButton:Clone()
ItemButton.Visible = true
ItemButton.Name = ItemName
ItemButton.Text = ItemName
ItemButton.Parent = itemFrame
local inventoryGui = script.Parent.Parent
local equipFrame = inventoryGui:WaitForChild("EquipFrame")
local equipButton = equipFrame:WaitForChild("EquipButton")
ItemButton.MouseButton1Click:Connect(function()
equipFrame.Title.Text = ItemName
equipFrame.Title.Visible = true
equipButton.Visible = true
end)
end
end)
InventoryScript:
local inventoryEvent = game.ReplicatedStorage.Remotes.InventoryEvent
game.Players.PlayerAdded:Connect(function(player)
local inventory = player:WaitForChild("Inventory")
local inventoryFrame = player.PlayerGui:WaitForChild("InventoryGui").InventoryFrame.ItemsFrame:GetChildren()
inventory.ChildAdded:Connect(function(Item)
inventoryEvent:FireClient(player, Item.Name, true)
end)
end)
inventoryEvent.OnServerEvent:Connect(function(player, ItemName, Value, button)
if Value == false then
local SelectedItem = player.Inventory:FindFirstChild(ItemName)
local backpack = player.Backpack:GetChildren()
local stuff = player.Character:GetChildren()
if #backpack == 0 and not player.Character:FindFirstChildWhichIsA("Tool") then
button.Text = "Unequip"
button.BackgroundColor3 = Color3.new(255,0,0)
SelectedItem:Clone().Parent = player.Backpack
else
for i,v in ipairs(backpack) do
button.Text = "Equip"
button.BackgroundColor3 = Color3.new(0,255,0)
v:Destroy()
end
for i, v in ipairs(stuff) do
if v:IsA("Tool") then
button.Text = "Equip"
button.BackgroundColor3 = Color3.new(0,255,0)
v:Destroy()
end
end
end
end
end)