Need help with my inventory gui

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).

(Image 1)

(Image 2)

(Image 3)

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)

4 Likes

Maybe you should show to use the code that Select the thing on the you’re client (gui)

2 Likes

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.

1 Like

it looks cool and sorry i don’t know what to do :frowning:

if you can’t fix it you should try using this one i found.

https://www.roblox.com/library/9227995784/Custom-Bar-Gui

sorry again i really don’t know what to do

2 Likes

yeah I did try this, but I still had no luck:

-- Equip Classic Sword
newTemplate.MouseButton1Click:Connect(function()

	if newTemplate.Title.Text == "Equip" and items.Name == "ClassicSword" then

		items:WaitForChild("Equipped").Value = true

		if items:WaitForChild("Equipped").Value == true then

			newTemplate.ViewportFrame.Name = "VF ClassicSword"
			newTemplate:FindFirstChild("VF ClassicSword").SlotUnequipped.Visible = false
			newTemplate:FindFirstChild("VF ClassicSword").SlotEquipped.Visible = true
			newTemplate.Title.Text = "Unequip"

			game.ReplicatedStorage.RemoteEvents.EquipClassicSword:FireServer()

		else if newTemplate.Title.Text == "Unequip" then

				items:WaitForChild("Equipped").Value = false
				newTemplate.Title.Text = "Equip"
				newTemplate:FindFirstChild("VF ClassicSword").SlotUnequipped.Visible = true
				newTemplate:FindFirstChild("VF ClassicSword").SlotEquipped.Visible = false

				game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
			end
		end
	end
end)

-- Equip Axe
newTemplate.MouseButton1Click:Connect(function()

	if newTemplate.Title.Text == "Equip" and items.Name == "Axe" then

		items:WaitForChild("Equipped").Value = true

		if items:WaitForChild("Equipped").Value == true then

			newTemplate.ViewportFrame.Name = "VF Axe"
			newTemplate:FindFirstChild("VF Axe").SlotUnequipped.Visible = false
			newTemplate:FindFirstChild("VF Axe").SlotEquipped.Visible = true
			newTemplate.Title.Text = "Unequip"

			game.ReplicatedStorage.RemoteEvents.EquipAxe:FireServer()

		else if newTemplate.Title.Text == "Unequip" then

				items:WaitForChild("Equipped").Value = false
				newTemplate.Title.Text = "Equip"
				newTemplate:FindFirstChild("VF Axe").SlotUnequipped.Visible = true
				newTemplate:FindFirstChild("VF Axe").SlotEquipped.Visible = false

				game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
			end
		end
	end
end)

1 Like

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.

2 Likes

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
Capture
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.

1 Like
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
				
1 Like

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.

1 Like

Ok yeah that would make sense I’ll try that out :grinning:

1 Like

Not sure exactly what you mean by change type template, so the name of the tool?

[Type] meaning what the template.ClassName is, whether it be a ImageLabel or a Frame or etc…

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.