So, in (Image 1) my tools. when a pick and select a tool that I want to use, the equip image is set to my item as it should, which is fine (Image 2), but if I select another tool, I want it to unequip the first tool and equip the second, but it just keeps selecting what I click on (Image 3).
Oh wow, you are doing the same function for every tool, i would suggest you to use a cicle for and put a Selected Value, However you should still put a selected value and then every time you click a new button re-enable the old things of that frame.
it’s cool bro I appreciate the custom bar, it’s really cool. But I’m pretty committed to this setup already. But if all else falls it might be my only option.
I have a bool value inside every item named Equipped
(items:WaitForChild(“Equipped”).Value = true)
It clones this WeaponSlot as a Template for ever new item bought at the shop and adds it the inventory gui
so every newTemplate has the same children and response to the code the same when newTemplate.mousebutton1clicked:connect, so I need to fine a way to make it check when one item is equipped all other items are unequipped.
for _, items in pairs(folder:GetChildren()) do
items:WaitForChild("Equipped").Value = false -- Phantom
local newTemplate = template:Clone()
newTemplate.Name = items.Name
newTemplate.Visible = true
newTemplate.Image = items.TextureId
newTemplate.Parent = frame.WeaponsScrollingFrame
newTemplate.Title.Visible = true
newTemplate.ViewportFrame.SlotUnequipped.Visible = true
newTemplate.Title.Text = "Equip"
newTemplate.MouseButton1Click:Connect(function()
if newTemplate.Title.Text == "Equip" and items.Name == "ClassicSword" then
--😁
items:WaitForChild("Equipped").Value = true -- Phantom
newTemplate.ViewportFrame.SlotUnequipped.Visible = false
newTemplate.ViewportFrame.SlotEquipped.Visible = true
newTemplate.Title.Text = "Unequip"
game.ReplicatedStorage.RemoteEvents.EquipClassicSword:FireServer()
else if newTemplate.Title.Text == "Equip" and items.Name == "Axe" then
--😁
items:WaitForChild("Equipped").Value = true
newTemplate.ViewportFrame.SlotUnequipped.Visible = false
newTemplate.ViewportFrame.SlotEquipped.Visible = true
newTemplate.Title.Text = "Unequip"
game.ReplicatedStorage.RemoteEvents.EquipAxe:FireServer()
else if newTemplate.Title.Text == "Equip" and items.Name == "Torch" then
--😁
newTemplate.ViewportFrame.SlotUnequipped.Visible = false
newTemplate.ViewportFrame.SlotEquipped.Visible = true
newTemplate.Title.Text = "Unequip"
game.ReplicatedStorage.RemoteEvents.EquipTorch:FireServer()
else if newTemplate.Title.Text == "Equip" and items.Name == "Pick" then
--😁
newTemplate.ViewportFrame.SlotUnequipped.Visible = false
newTemplate.ViewportFrame.SlotEquipped.Visible = true
newTemplate.Title.Text = "Unequip"
game.ReplicatedStorage.RemoteEvents.EquipPick:FireServer()
else if newTemplate.Title.Text == "Equip" and items.Name == "M9" then
--😁
newTemplate.ViewportFrame.SlotUnequipped.Visible = false
newTemplate.ViewportFrame.SlotEquipped.Visible = true
newTemplate.Title.Text = "Unequip"
game.ReplicatedStorage.RemoteEvents.EquipM9:FireServer()
else if newTemplate.Title.Text == "Unequip" then
--😁
items:WaitForChild("Equipped").Value = false
newTemplate.ViewportFrame.SlotEquipped.Visible = false
newTemplate.ViewportFrame.SlotUnequipped.Visible = true
newTemplate.Title.Text = "Equip"
game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
end
end
end
end
end
end
end)
I don’t know if this will work but I think what you need to do is, where you see the smiling faces you need to refresh the all the newTemplate back to normal and then run the code to change the items under newTemplate. Check the example below to see what I would put where the smiling faces are.
Do know this method is very exploitable and I could find many ways to equip two items at once, and I don’t know if you have a debounce on the server side so I could try spamming the event as well. Take this into mind!
Example[should be used as an example and not source]:
for i,v in pairs(frame.WeaponsScrollingFrame:GetChildren()) do
if v:IsA(template.ClassName) then v.Title.Text = "Equip" end
--you can change the type(template) to what newTemplate classname is .
end
ok I kind of understand what you’re saying, I’ll trying it out and let you know. I don’t have a debounce I thought about adding one but really haven’t use them before I’m pretty new to coding. If you have so I could add you to team create, and you can check out for yourself.
I didn’t look in too much detail, but you you use a remote event to equip, but you didn’t use one to unequip. This would explain one is overwriting the other.
If I was to add you to team create would you be able to show me? I looking to hire someone at this point because I can’t figure it out and I can’t move forward with my game until this is finished. At this point I don’t even care if we start over with shop/inventory, if there’s no way around fixing the problem. Let me know know if you would be interested.