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 cerrar_gui
local boton = script.Parent
local gui = boton:FindFirstAncestorOfClass("ScreenGui")
local ps = game:GetService("ProximityPromptService")
function cerrar()
gui.Enabled = false
end
boton.MouseButton1Click:Connect(cerrar)
ps.PromptHidden:Connect(cerrar)
this is Comprar_Item
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)
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)
also the tools have attributes and replicated storage
this is replicated storage attributes
and this is the tools attributes ( each one have the same ones)
any help would be good