hello im a semi-new roblox developer and im trying to create a sell system to improve my coding. In this system players can put thier items up for sale and other players can purchase them (like a marketplace).
my problem is that when a player puts a item up for sale i dont know how to clone the template. since i want all the players to see what the player put up for sale i dont know if i should clone the template on the server side or client side. I have 2 remote events to handle selling and buying which have not been used in my code yet.
-- local rep = game:GetService("ReplicatedStorage")
local openDealerEvent = rep.OpenDealer
local sellEvent = rep.SellItem
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.Character:Wait()
local gui = script.Parent
local itemsForSaleFrame = gui.ItemsForSaleFrame
local closeitemsbutton = itemsForSaleFrame.CloseButton
local GoToSellPageButton = itemsForSaleFrame.SellButton
local itemsFrame = itemsForSaleFrame.ItemsFrame
local itemsScrollingFrame = itemsFrame.ItemsScrollingFrame
local template = script.Template
local priceText = template.PriceFrame.PriceTextLabel
local toolNameText = template.ToolNameFrame.ToolNameTextLabel
local purchaseButton = template.BuyButton
local toolImage = template.ToolImage
local sellYourItemsFrame = gui.SellYourItemsFrame
itemsForSaleFrame.Visible = false
sellYourItemsFrame.Visible = false
local backbutton = sellYourItemsFrame.BackButton
local sellFrame = sellYourItemsFrame.SellFrame
local DetialsFrame = sellFrame.DetailsFrame
local SellToolName = DetialsFrame.SellToolNameFrane.ToolNameToSellText
local SellToolImage = DetialsFrame.ToolImage
local SellPriceText = sellFrame.PriceTextFrame.PriceText
local SubtractButton = sellFrame.SubtractPriceButton
local AddPriceButton = sellFrame.AddPriceButton
local sellButton = sellFrame.SellButton
local SellPrice = SellPriceText.SellPrice
local function CloneTemp(player)
end
SellPriceText.Text = "$" .. tostring(SellPrice.Value)
SellPrice:GetPropertyChangedSignal("Value"):Connect(function()
SellPriceText.Text = "$" .. tostring(SellPrice.Value)
end)
AddPriceButton.MouseButton1Click:Connect(function()
SellPrice.Value += 25
end)
SubtractButton.MouseButton1Click:Connect(function()
if SellPrice.Value >= 25 then
SellPrice.Value -= 25
else
SellPrice.Value = 0 -- Set SellPrice to 0 if it's below 25
end
end)
openDealerEvent.OnClientEvent:Connect(function()
if itemsForSaleFrame.Visible == false then
itemsForSaleFrame.Visible = true
elseif itemsForSaleFrame.Visible == true then
itemsForSaleFrame.Visible = false
end
end)
closeitemsbutton.MouseButton1Click:Connect(function()
itemsForSaleFrame.Visible = false
sellYourItemsFrame.Visible = false
end)
GoToSellPageButton.MouseButton1Click:Connect(function()
itemsForSaleFrame.Visible = false
sellYourItemsFrame.Visible = true
end)
backbutton.MouseButton1Click:Connect(function()
itemsForSaleFrame.Visible = true
sellYourItemsFrame.Visible = false
end)