Attempt to index nil with 'Value'

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I’m trying to make a robux marketplace system similar to pls buy me or starving artists

  1. What is the issue? Include screenshots / videos if possible!

I’ve run into an error

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Nothing found in developer fourm

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

This is the script used to send the message to the server:

local Button = script.Parent
local UploadedItem = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("UploadedItem")
local plr = game:GetService("Players").LocalPlayer

	local ItemsFrame = script.Parent.Parent

	local CurrentSelected = ItemsFrame:FindFirstChild("Selected")

	if CurrentSelected then
		CurrentSelected.Name = CurrentSelected.Config.ItemKey.Value

	Button.Name = "Selected"

	local PriceSelected = ItemsFrame.Parent.PricesFrame:FindFirstChild("Selected")

	if PriceSelected then
		UploadedItem:FireServer(PriceSelected.Id, Button.Config.ItemKey.Value)

This is the server recieving the message and sending one back to the client:

UploadedItem.OnServerEvent:Connect(function(plr, GamepassId, Card)
		local PlayerName = plr.Name
		local Info = MarketplaceService:GetProductInfo(GamepassId.Value, Enum.InfoType.GamePass)
		local Price = Info.PriceInRobux
		local CardURL = UploadItemTemplates[Card].Image
		local CardBackgroundColour3 = UploadItemTemplates[Card].BackgroundColor3
		UploadedItem:FireAllClients(PlayerName, Price, GamepassId, CardURL, CardBackgroundColour3, Card)

This is the script for the client recieving that event

local UploadedItem = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("UploadedItem")

UploadedItem.OnClientEvent:Connect(function(PlayerName, Price, GamepassId, CardURL, CardBackgroundColor3, Card)
	local SellerTemplate = script.Parent.ShopFrame.Template
	local NewSellFrame = SellerTemplate:Clone()
	NewSellFrame.Name = "SellFrame"
	NewSellFrame.Parent = SellerTemplate.Parent
	NewSellFrame.GamepassId.Value = GamepassId.Value
	local Info = NewSellFrame.Info
	Info.ItemPrice.Text = Price
	Info.Seller.Text = PlayerName
	Info.Parent.Showcase.ItemLabel.Image = CardURL
	Info.Parent.Showcase.BackgroundColor3 = CardBackgroundColor3
	Info.ItemKey.Value = Card
	NewSellFrame.Visible = true

This is where it gets weird. On the client that sent the first message, it runs without errors. On any other client, I get an error.

The error: Players.Player1.PlayerGui.MarketplaceGui.MarketplaceFrame.LocalScript:9: attempt to index nil with ‘Value’

1 Like

It means the NewSellFrame you cloned does not contain a child named GamepassId

1 Like

Yes but it works on the player thats firing the first one so idk whats the issue

1 Like

The client that passes on the values to the server doesn’t use SellFrame at all, so there’s no reason for there to be same error as in the last block. Double-check whether SellFrame contains a child named “GamepassId”

I’ve checked and gamepassid is there.

1 Like

Strange, can you provide pictures?

I’ve fixed by removing the second .Value. But now theres another bug; whenever a player buys the gamepass it doesn’t give the item to the other player and it doesn’t take away from the inventory of the seller.

PlayerBoughtItem.OnServerEvent:Connect(function(plr, ItemOwner, ItemSelected)
	Main.RemoveFromInventory(game.Players[ItemOwner], ItemSelected)
	Main.AddToInventory(plr, ItemSelected)
function Main.RemoveFromInventory(plr, ItemKey)
	local Data = plr:WaitForChild("Data")
	local InventoryString = plr:WaitForChild("Inventory")
	local InventoryTable = Main.ConvertToTable(InventoryString.Value)
	local ItemToRemove = table.find(InventoryTable, ItemKey)
	table.remove(InventoryTable, ItemToRemove)
	InventoryString.Value = Main.ConvertToString(InventoryTable)

function Main.AddToInventory(plr, ItemKey)
	local Data = plr:WaitForChild("Data")
	local InventoryString = plr:WaitForChild("Inventory")
	InventoryString.Value = InventoryString.Value..ItemKey

Btw inventory is stored as a stringvalue in a folder in the player.

Could you print out in both client and server event what gamepassid is

as I said, the main issue is resolved. i just have another error now

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.