Shop with seller bug with no error on output

I wanna make a store with a seller where you can buy weapons with points and also with datastore save

The gui can open but when i click the button to buy a item i dont get on the backpack and also the points doesnt subtracts

this is the script of Prompt_Tienda

local prompt = script.Parent

local rs = game:GetService("ReplicatedStorage")

local MostrarTienda = rs:WaitForChild("MostrarTienda")


prompt.Triggered:Connect(function(jugador)

	MostrarTienda:FireClient(jugador, prompt:GetAttribute("item_type"))

end)

this is tienda_gui script

local rs = game:GetService("ReplicatedStorage")
local NombreMoneda = rs:GetAttribute("moneda")


local MostrarTienda = rs:WaitForChild("MostrarTienda")
local jugador = game.Players.LocalPlayer
local gui = script.Parent


function Abrir(item_type)
local saldo = gui.Main.Footer.Saldo
saldo.Text = jugador.leaderstats[NombreMoneda].Value

local items = gui.Main.Items
	for i, itemGui in pairs(items:GetChildren()) do
		if itemGui:IsA("Frame") then
			itemGui:Destroy()
		end
	end


	for i, item in pairs(rs.Items:GetChildren()) do
		if item:GetAttribute("type") == item_type or item_type == "todos" then
			local itGui = rs.gui.Item:Clone()
itGui.Imagen.Image = item.TextureId
itGui.Info.Titulo.Text = item.Name
itGui.Info.Precio.Text = item:GetAttribute("precio").." G"
itGui.Parent = items

itGui:SetAttribute("item_id", item:GetAttribute("item_id"))
itGui:SetAttribute("item_type", item_type)
		end
		
	end


gui.Enabled = true
end



MostrarTienda.OnClientEvent:Connect(Abrir)

this is Compras script

local rs = game:GetService("ReplicatedStorage")

local ComprarItem = rs:WaitForChild("ComprarItem")
local MostrarTienda = rs:WaitForChild("MostrarTienda")
local NombreMoneda = rs:GetAttribute("moneda")

function Comprar(jugador, item_id, item_type)
	for i, item in pairs(rs.Items:GetChildren()) do
		if item:GetAttribute("item_id") == item_id then
			local dinero = jugador.leaderstats[NombreMoneda]
			local precio = item:GetAttribute("precio")
			if dinero.Value >= precio then
				dinero.Value = dinero.Value - precio
				
				local it = item:Clone()
				it.Parent = jugador.Backpack
				
				MostrarTienda:FireClient(jugador, item_type)
				
			end
		end
	end
end

ComprarItem.OnServerEvent:Connect(Comprar)

this is Comprar_Item script

local boton = script.Parent
local itGui = script.Parent
local rs = game:GetService("ReplicatedStorage")
local ComprarItem = rs:WaitForChild("ComprarItem")

boton.MouseButton1Click:Connect(function()
	
	ComprarItem:FireServer(itGui:GetAttribute("item_id"), itGui:GetAttribute("item_type"))
	
end)

the ReplicatedStorage and the Items have attributes also
Capturaaaaa

and replicated storage
Capturad

now the locations of the scripts
Capturaxdddd
fotoxd
segundafotito

there also 2 RemoteEvent on replicated storage

adasd

someone can help me pls?

2 Likes

anyone can help me?
why nobody answer

1 Like

This is probably due to a logical error, why don’t you try to put some prints to see where the code stops working?

1 Like

on tienda_gui and comprar_item scripts the prints doesnt work but no problem appears on output
thats the error maybe ( but the gui can still be opened tho)

I think I found one issue. On the Comprar_Item script, you send the attribute called “item_type”, but it’s supposed to be just “type” right?

1 Like

i think i found a issue
asddd

and also on tienda_gui script its supposed to set item_type attribute to itGui but it doesnt work

1 Like

Try these prints and see if it works all the way through.
For example, in the prompt_tienda, add a print statement in the prompt.Triggered:Connect(function(jugador)

After that, add a print statement in at the beginning of Abrir function to make sure it works.

After that add a print statement in the MouseButton1Click to make sure thats working.
After that add a print statement in Comprar function to make sure thats working.

If all those works, then you gotta check all the functions piece by piece.
So make sure Abrir is doing whatever you want it to do properly and so on and so forth.

1 Like

it says ServerScriptService.Compras:13: attempt to compare string <= number when i touch the button to buy

can you show the attributes of the prompt? I am starting to get a lil confused lol

prompt

1 Like

Is item_type supposed to be a number like 1,2,3… or a string like “sword”?

item_type is a string on the prompt

is the error you’re getting on line “item:GetAttribute(“item_id”) == item_id then”?

1 Like

is this line
image
line 13 on Compras script

1 Like

image
this is the dinero variable

2 Likes

Dinero is a int right? not a string

2 Likes

its the money you have on the leaderstats

1 Like

Is it set up like “1000” or 1000? whatever the value is

2 Likes

image
basically you have to touch coins to get the points and buy items on the shop

2 Likes