Need help with a shop gui

Im trying to make a shop gui so i followed this tutorial here but the problem is whenever im trying to eqquip i can only equip one tool at a time and i want to equip multiple tools like tool1,tool2,tool3 at the same time and i dont know how here is the tutorial i followed

Link

How to make a TOOL SHOP GUI | ROBLOX STUDIO 2020 - YouTube

My game link

Test - Roblox

Test.rbxl (60.7 KB)

Shop Main script(server)
local dsService = game:GetService("DataStoreService")
local ds = dsService:GetDataStore("ShopGui14")


game.Players.PlayerAdded:Connect(function(player)

	local folder = Instance.new("Folder", player)
	folder.Name = "OwnedItems"
	local save = ds:GetAsync(player.UserId)

	if save then
		for i, tool in pairs(save) do
			local bool  = Instance.new("BoolValue")
			bool.Name = tool
			bool.Parent = folder
		end
	else
		for i, tool in pairs(game.ServerStorage.Tools:GetChildren()) do

			if tool:FindFirstChild("ItemNumber") then
				if tool.ItemNumber.Value == 1 then
					local bool  = Instance.new("BoolValue")
					bool.Name = tool.Name
					bool.Parent = folder
				end
			end
		end
	end

end)


game.ReplicatedStorage.Remotes.BoughtTool.OnServerEvent:Connect(function(player, item)

	local tool = game.ServerStorage.Tools:FindFirstChild(item)
	local cost = tool.Cost.Value
	if player.leaderstats.Cash.Value >= cost then
		player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - cost
		local bool = Instance.new("BoolValue")
		bool.Name = item
		bool.Parent = player.OwnedItems

		game.ReplicatedStorage.Remotes.BoughtTool:FireClient(player, item)

		local purchased = {}
		for i, name in pairs(player.OwnedItems:GetChildren()) do
			table.insert(purchased,name.Name)
		end
		ds:SetAsync(player.UserId, purchased)
	end

end)

game.Players.PlayerRemoving:Connect(function(player)
	local purchased = {}
	for i, name in pairs(player.OwnedItems:GetChildren()) do
		table.insert(purchased,name.Name)
	end
	ds:SetAsync(player.UserId, purchased)
end)
ServerToReplicatedStorage(server)
for i, tool in pairs(game.ServerStorage:WaitForChild("Tools"):GetChildren()) do

	if tool:IsA("Tool") then
		local new = Instance.new("ImageLabel")
		new.Image = tool.TextureId
		new.Name = tool.ItemNumber.Value
		local name = Instance.new("StringValue", new)
		name.Name = "ToolName"
		name.Value = tool.Name
		local cost = Instance.new("NumberValue", new)
		cost.Name = "Cost"
		cost.Value = tool.Cost.Value
		new.Parent = game.ReplicatedStorage.ToolsImage
	end

end



local isthere = 0
for i, v in pairs(game.ServerStorage.Tools:GetChildren()) do
	isthere = isthere+1
end

local new = Instance.new("NumberValue", game.ReplicatedStorage)
new.Name = "TotalTools"
new.Value = isthere
PlayerLoadedListener(server)
game.ReplicatedStorage.Remotes.PlayerLoaded.OnServerEvent:Connect(function(player)
	print("Player Loaded")
	local thereis = 0
	local inplace = 0

	repeat
		thereis = 0
		inplace = 0
		for i, tool in pairs(game.ServerStorage.Tools:GetChildren()) do
			thereis = thereis+1
		end
		for i, image in pairs(game.ReplicatedStorage.ToolsImage:GetChildren()) do
			inplace = inplace+1
		end
		print(thereis)
		wait(0.1)
	until thereis == inplace
	print(thereis)
	print("GoingTofire")
	wait(3)
	print("Fires")
	game.ReplicatedStorage.Remotes.BeginArrangement:FireClient(player)
end)
LastEquipped(server)
local dsService = game:GetService("DataStoreService")
local ds = dsService:GetDataStore("LastEquippedShop11")



game.ReplicatedStorage.Remotes.PlayerLoaded.OnServerEvent:Connect(function(player)
	local equippedlast = Instance.new("StringValue")
	equippedlast.Name = "Equipped"
	local save = ds:GetAsync(player.UserId)
	if save then
		equippedlast.Value = save
	else
		local name
		for i, tool in pairs(game.ServerStorage.Tools:GetChildren()) do
			if tool:FindFirstChild("ItemNumber") then
				if tool.ItemNumber.Value == 1 then
					name = tool.Name

				end
			end
		end
		equippedlast.Value = name
	end

	equippedlast.Parent = player

	local clone = game.ServerStorage.Tools:FindFirstChild(equippedlast.Value):Clone()
	clone.Parent = player:WaitForChild("Backpack")

end)



game.Players.PlayerRemoving:Connect(function(player)

	ds:SetAsync(player.UserId, player.Equipped.Value)

end)
EquipTool(server)
game.ReplicatedStorage.Remotes.EquipTool.OnServerEvent:Connect(function(player, item)

	if player.OwnedItems:FindFirstChild(item) then
		for i, ifthere in ipairs(player.Backpack:GetChildren()) do
			ifthere:Destroy()
		end
		for i, ifthere in pairs(player.Character:GetChildren()) do
			if ifthere:IsA("Tool") then
				if game.ServerStorage.Tools:FindFirstChild(ifthere.Name) then
					ifthere:Destroy()
				end
			end
		end
		local clone = game.ServerStorage.Tools:FindFirstChild(item):Clone()
		clone.ItemNumber:Destroy()
		clone.Cost:Destroy()
		clone.Parent  = player.Backpack
		player.Equipped.Value = item
		game.ReplicatedStorage.Remotes.EquipTool:FireClient(player, item)
	end

end)
LocalScript inside buybutton(local)
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	local item = script.Parent.Parent.Parent.NameOftool.TextLabel.Text

	if script.Parent.Text == "Buy" then
		game.ReplicatedStorage.Remotes.BoughtTool:FireServer(item)
	elseif script.Parent.Text == "Equip" then
		game.ReplicatedStorage.Remotes.EquipTool:FireServer(item)
	end

end)


game.ReplicatedStorage.Remotes.BoughtTool.OnClientEvent:Connect(function(item)

	game.ReplicatedStorage.Remotes.EquipTool:FireServer(item)
	print("Recieves")
	local number = 0
	for i,v in pairs(script.Parent.Parent.Parent.Parent.ScrollingFrame_12.ScrollingFrame:GetChildren()) do
		if v:FindFirstChild("ToolName") then
			if v.ToolName.Value == item then
				number = tonumber(v.Name)
			end
		end
	end

	if number ~=nil then
		for i,v in pairs(script.Parent.Parent.Parent.Parent.ScrollingFrame_12.ScrollingFrame:GetChildren()) do
			if v:FindFirstChild("ToolName") then
				local thenumber = tonumber(v.Name)
				if thenumber <=number or thenumber == number +1 then
					v.ToolImageDisp.ImageLabel.ImageColor3 = Color3.fromRGB(255,255,255)
				end
			end
		end
	end

	for i, v in pairs(script.Parent.Parent.Parent.Parent.ScrollingFrame_12.ScrollingFrame:GetChildren()) do
		if v:FindFirstChild("ToolName") then
			if v.ToolImageDisp.ImageLabel.Image == script.Parent.Parent.Parent.ImageOftool.Image then
				if v.ToolImageDisp.ImageLabel.ImageColor3 == Color3.fromRGB(255,255,255) then
					script.Parent.Parent.Parent.ImageOftool.ImageColor3 = Color3.fromRGB(255,255,255)
				end
			end
		end
	end


end)

game.ReplicatedStorage.Remotes.EquipTool.OnClientEvent:Connect(function(item)
	if script.Parent.Parent.Parent.NameOftool.TextLabel.Text == item then
		script.Parent.Text = "Equipped"
	end

end)
Local Script that arranges things in the scrollling frame(local)
game.ReplicatedStorage.Remotes.PlayerLoaded:FireServer()
print("PlayerLoaded")
local player = game.Players.LocalPlayer
local number = 1
game.ReplicatedStorage.Remotes.BeginArrangement.OnClientEvent:Connect(function()
	print("Got")
	repeat
		local image = game.ReplicatedStorage.ToolsImage:FindFirstChild(number)
		if image:IsA("ImageLabel") then
			print(image.Name)
			local clone = game.ReplicatedStorage.Template:Clone()
			clone.ToolImageDisp.ImageLabel.Image = image.Image
			clone.Name = image.Name
			clone.CostDisplay.Value = image.Cost.Value
			clone.ToolName.Value = image.ToolName.Value
			clone.Parent = script.Parent
			clone.ToolImageDisp.ImageLabel.ImageColor3 = Color3.fromRGB(0,0,0) 

			if clone.Name == "1" then
				local sidemenu = script.Parent.Parent.Parent.SideMenu
				sidemenu.ImageOftool.Image = image.Image
				sidemenu.ImageOftool.ImageColor3 = Color3.fromRGB(255,255,255)
				sidemenu.BuyButton.TextButton.Text = "Equip"
				sidemenu.Cost.CostOfTool.Value = 0
				sidemenu.Cost.CostDisplayer.Text = "Cost : 0"
				sidemenu.NameOftool.TextLabel.Text = clone.ToolName.Value

			end

			if player.OwnedItems:FindFirstChild(clone.ToolName.Value) then
				clone.ToolImageDisp.ImageLabel.ImageColor3 = Color3.fromRGB(255,255,255)
			end

			local equipped = player:WaitForChild("Equipped")
			if equipped.Value~= nil then
				if clone.ToolName.Value == equipped.Value then
					local sidemenu = script.Parent.Parent.Parent.SideMenu
					sidemenu.ImageOftool.Image = image.Image
					sidemenu.ImageOftool.ImageColor3 = Color3.fromRGB(255,255,255)
					sidemenu.BuyButton.TextButton.Text = "Equipped"
					sidemenu.Cost.CostOfTool.Value = clone.CostDisplay.Value
					sidemenu.Cost.CostDisplayer.Text = "Cost : "..sidemenu.Cost.CostOfTool.Value
					sidemenu.NameOftool.TextLabel.Text = clone.ToolName.Value
					game.ReplicatedStorage.Remotes.EquipTool:FireServer(equipped.Value)
				end
			end

			local number = tonumber(clone.Name)
			if number ~= 1 then
				local previousnum = number-1
				local itemfound = script.Parent:FindFirstChild(previousnum)
				if itemfound then
					if player.OwnedItems:FindFirstChild(itemfound.ToolName.Value) then
						clone.ToolImageDisp.ImageLabel.ImageColor3 = Color3.fromRGB(255,255,255) 
					end 
				end
			end
		end
		number = number+1
	until number == game.ReplicatedStorage.TotalTools.Value + 1
end)

everything works except that i want to equip multiple tools at once
if you need anything else pls ask thanks
if anyone knows any tutorial that has everything that i stated pls tell me

Why are you destroying all of the player’s tools?

		for i, ifthere in ipairs(player.Backpack:GetChildren()) do
			ifthere:Destroy()
		end
1 Like

as i said i followed a tutorial so i need help making it so i can equip multiple tools and i dont know how

1 Like

hi i made it working!!
i followed this tutorial this tutorial isnt exactly a tool shop but its a pet shop but i changed some part of the script to be a tool shop now it works so great!!