How would I check if a player owns a tool?

wait, what is the for loop for since it’s only running once and the tool may not be loaded when the gui loads so that it doesn’t display the ‘OWNED’ (basically the gui updates faster than the tool loading, maybe(?))

maybe add an object value inside all the “Buy” buttons and set the value to the specific tool and then, inside your “Open shop” gui add this script

for _, v in pairs(script.Parent:GetChildren()) do
    if v.Name == "Buy" then
        local item = v.ObjectValue.Value
        if game.Players.LocalPlayer.Backpack:FindFirstChild(item.Name) then
            v.Name = "OWNED"
        end
    end
end

The for loop is for replicating the same template (the one you saw in the photo) in a list layout for every tool

oh so it load automatically for all the tool in the replicated storage, i get it now, ignore the post above it’s wrong

Yep.

Also, I tried something similar to this however it didn’t work.

if game.Players.LocalPlayer.Backpack:FindFirstChild(tool.Name) then
		button.Name = "OWNED"
	end

try doing,

local folder = game.ReplicatedStorage:WaitForChild("Tools")
local frame = script.Parent
local template = frame.shoptemplate

template.Visible = false

for _, tool in pairs(folder:GetChildren()) do
	local newTemplate = template:Clone()
	local button = newTemplate.Buy
	newTemplate.Parent = frame
	newTemplate.Visible = true
	newTemplate.Name = tool.Name
	newTemplate.TextLabel.Text = tool.Name
	newTemplate.Buy.Text = "$"..tool.Cost.Value

    task.wait(1)
    if game.Players.LocalPlayer.Backpack:FindFirstChild(tool.Name) then
         newTemplate.Buy.Text = "OWNED"
    end
	
	button.MouseButton1Click:Connect(function()
		local result = game.ReplicatedStorage.BuyItem:InvokeServer(tool.Name)

		if result == true then
			--
		else
			--
		end
	end)
end

That seemed to work. Thank you so much.

Wait, I just noticed something. When you buy the BloxyCola, it doesn’t update, how would I do that?

Like the gui text doesn’t.

in your buy script, when it’s successful you can just disable the button and change the text to “OWNED”

I’ll just have to figure it out for now, but here, you take the solution.

try doing this, if i’m right then it should work.

local folder = game.ReplicatedStorage:WaitForChild("Tools")
local frame = script.Parent
local template = frame.shoptemplate

template.Visible = false

for _, tool in pairs(folder:GetChildren()) do
	local newTemplate = template:Clone()
	local button = newTemplate.Buy
	newTemplate.Parent = frame
	newTemplate.Visible = true
	newTemplate.Name = tool.Name
	newTemplate.TextLabel.Text = tool.Name
	newTemplate.Buy.Text = "$"..tool.Cost.Value

    task.wait(1)
    if game.Players.LocalPlayer.Backpack:FindFirstChild(tool.Name) then
         newTemplate.Buy.Text = "OWNED"
    end
	
	button.MouseButton1Click:Connect(function()
		local result = game.ReplicatedStorage.BuyItem:InvokeServer(tool.Name)

		if result == true then
			newTemplate.Buy.Text = "OWNED"
		else
			--
		end
	end)
end

That worked, thanks!

local rs = game:GetService("ReplicatedStorage")

rs.BuyItem.OnServerInvoke = function(player,toolName)
	local tool = rs.Tools:FindFirstChild(toolName)
	if tool and not player.Backpack:FindFirstChild(toolName) then
		if tool:FindFirstChild("Cost") then
			if tool.Cost.Value <= player.leaderstats.Coins.Value then
				player.leaderstats.Coins.Value -= tool.Cost.Value
				local newTool = tool:Clone()
				newTool.Parent = player.Backpack
				local newTool = tool:Clone()
				newTool.Parent = player.StarterGear
				return true
			end
		end
	end
end

You should be checking the player’s backpack instead.

Alright.

Ah forgive me, I got confused as to what the remote was doing. Thanks for pointing that out though.