I took a break from scripting for almost half a year. Don’t beat me up for implementing everything on the client. Also, keep in mind that the two players have money in common, so they are not tied to the player, but to the value inside the replicated store
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ShopFolders = script.Parent
local objectUIsFolder = ReplicatedStorage.ObjectUis
wait(2)
local function cloneFrames()
for _, folder in (objectUIsFolder:GetChildren()) do
local scrollingFrameShop = ShopFolders:FindFirstChild(folder.Name)
for _, frame in (folder:GetChildren()) do
if frame:IsA("Frame") then
local clonedFrame = frame:Clone()
clonedFrame.SelectBTN.SelectBTN.Text = "Buy"
clonedFrame.Parent = scrollingFrameShop
for i,player in game.Players:GetChildren() do
clonedFrame.SelectBTN.SelectBTN.MouseButton1Click:Connect(function()
local RS = game.ReplicatedStorage.RS
local Cost = clonedFrame.Cost
local CurrectBalance = RS.Value
local CurrectCost = Cost.Value
if CurrectBalance < CurrectCost then return end
RS.Value -= CurrectCost
local InventoryClonedFrame = frame:Clone()
local InventoryFolders = player.PlayerGui.Inventory.Folders
InventoryClonedFrame.Parent = InventoryFolders:FindFirstChild(folder.Name)
InventoryClonedFrame.SelectBTN.SelectBTN.MouseButton1Click:Connect(function()
player.Character.Obj.Value = InventoryClonedFrame
player.Character.Obj.Type.Value = folder.Name
end)
end)
end
end
end
end
end
cloneFrames()
I know that there is something wrong with the code due to the fact that I use for i, players (if anything, yes, I am trying to implement a SHARED inventory for players)
However, for some reason, my friend just said that he bought an item and it did not appear in anyone’s inventory, but for me (I created the server) - yes
InventoryClonedFrame.SelectBTN.SelectBTN.MouseButton1Click:Connect(function()
player.Character.Obj.Value = InventoryClonedFrame
player.Character.Obj.Type.Value = folder.Name
end)
The problem is also similar, Only 1 player can choose something, and the second player has a strange bug - He chose and the Type changed, But the objectValue did not
I also have problems with this line. I made it on the server. It seems like it should be, BUT DAMN it, I do not know how to make this particular line work only for the clicked player (obviously, FireAllClient, I just thought, tell me if I’m wrong)
help… I’ve been working on this code for an hour now