confused on why this is equipping more tools than normal(happens mainly when you click on more than a tool), was following this tutorial (https://www.youtube.com/watch?v=GnXB4eAOVkY) but changed a few parts on it
ocal invevent = game.ReplicatedStorage.InventoryEvent
local itemframe = script.Parent.InventoryFrame:FindFirstChild("Frame")
local Showcase = itemframe.Parent.Parent.ShowCaseGun
invevent.OnClientEvent:Connect(function(Itemname, ItemToolTip, Value)
if Value == true then
local itembutton = itemframe.ButtonHolders:FindFirstChild(ItemToolTip):Clone()
itembutton.Visible = true
itembutton.Name = Itemname
itembutton.Named.Text = ItemToolTip
itembutton.Parent = itemframe
itembutton.Click.MouseButton1Click:Connect(function()
Showcase.Visible = true
Showcase.GunName.Text = ItemToolTip
Showcase.N1.Text = itembutton.DamageH.Value
Showcase.N2.Text = itembutton.DamageT.Value
Showcase.N3.Text = itembutton.DamageL.Value
Showcase.N4.Text = itembutton.FireRate.Value
Showcase.Equip.MouseButton1Click:Connect(function()
itembutton:Destroy()
invevent:FireServer(Itemname, false)
Showcase.Visible = false
end)
end)
end
end)
heres server script if needed to help with it
local invevent = game.ReplicatedStorage.InventoryEvent
game.Players.PlayerAdded:Connect(function(Player)
local Anventory = Instance.new("Folder", Player)
Anventory.Name = "Inventory"
Anventory.ChildAdded:Connect(function(Item)
invevent:FireClient(Player, Item.Name, Item.ToolTip, true)
end)
invevent.OnServerEvent:Connect(function(Player, ItemName, Value)
if Value == false then
local selecteditem = Player.Inventory:FindFirstChild(ItemName)
if selecteditem:IsA("Tool") then
selecteditem.Parent = Player.Backpack
elseif selecteditem:IsA("NumberValue") then
return
end
end
end)
end)
