Attempt to index nil 'Value' error

So i keep getting this error “Attempt to index nil Value” in my server script. Im not sure how to fix this… Can you please help?



			game.ReplicatedStorage.Remotes.BuyItem.OnServerEvent:Connect(function(thisplr)
	local finditem = thisplr:FindFirstChild("ViewItem")
	local newskin = Instance.new("StringValue")
	newskin.Name = finditem.Value
	newskin.Parent = thisplr.EventItemsValuesFolder
	print("Recieved!")
			end)
			
		
1 Like

Where is “ViewItem” supposed to be? inside the player like this?
image

change your code to this:

game.ReplicatedStorage.Remotes.BuyItem.OnServerEvent:Connect(function(thisplr)
	local finditem = thisplr:FindFirstChild("ViewItem")
	if not finditem then print("cannot find ViewItem inside the player") return end
	
	local newskin = Instance.new("StringValue")
	newskin.Name = finditem.Value
	newskin.Parent = thisplr.EventItemsValuesFolder
	print("Recieved!")
end)

the error means that “viewitem” is not found inside the player

3 Likes

it says its not there but “viewItem” is inside the player tho

That means that you didnt spell the name of the value the exact same . make sure the capitals and spelling in the code is the exact same as the value inside the player

Thank you so much it works now, could u help me with 1 more thing please?

Im having a problem whenever someone buys the item the new Value name is supposed to be the “ViewItem” .Value = “ITEMNAME” but when the person buys the item it create the name is Blank and it dosent add the items name (idk if that made sense or not )

Yeah that didn’t make too much sense to me :joy:. Do you mind trying to explain it to me again?

1 Like

A better example is that the item name that goes in to datastore of the bought item is blank when a script is suposed to get the ViewItem.Value as the name of the value but its not

Hmm, does this code do what you want?

			game.ReplicatedStorage.Remotes.BuyItem.OnServerEvent:Connect(function(thisplr)
				local finditem = thisplr:FindFirstChild("ViewItem")
				if not finditem then print("cannot find ViewItem inside the player") return end

				local newskin = Instance.new("StringValue")
				newskin.Name = finditem.Value
				newskin.Value = finditem.Value
				newskin.Parent = thisplr.EventItemsValuesFolder
			end)
1 Like

yes that is the code script that runs it

ohhhh it looks like the “ViewItem” value is blank like this:


Is there supposed to be code to set the value to something? Because it doesnt seem to be working.

yea i have a code in my catalog script for it

game.Players.LocalPlayer:FindFirstChild(“ViewItem”).Value = v[“Name”]

when you go into the game, can you check if the value is changing for the “ViewItem” or if it is just blank?

the viewItem value name dosent change and the value is the item name but when i buy the item and add a new value to the eventfolder the name and value is blank

so when i click on the item i want it dont buy right then but it adds a value to the player that is the name “Viewitem” and the value as the item im looking at but when i buy the item the new value is blank

Sorry, but do you mind giving me access to the game? If your not comfortable that’s fine but it’s just hard to troubleshoot when I can’t see the rest of the code, or how the values are changing.

1 Like

Im trying to finish this shop so idc XD let me add u on roblox and ill give u perm to game.

Your added


alright i’m going to take a look right now

1 Like

also sorry if my game is a lil mess

The code script to look at are
Catalog in the menu gui
and the scripts in server script

arlight thankssssssssssssssssssss

1 Like