Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Attempt to index nil with 'Price'?

It says in the output that i am trying to index nil with price in this, the error is on line 7 help pls.

game.Players.PlayerAdded:Connect (function(player)
	local pg = player:WaitForChild('PlayerGui')
	local Main = pg:WaitForChild('Main')
	for i , v in pairs(Main.PetShop.ScrollingFrame:GetChildren()) do
		if v.Name ~= 'Template' and v:IsA('Frame') then
			v.PetPrice.Text=
game.ReplicatedStorage:WaitForChild('Pets'):FindFirstChild(v.Name).Price.Value
			v.PetName.Text = game.ReplicatedStorage:WaitForChild('Pets'):FindFirstChild(v.Name).Name
		end
	end
end)


3 comments

0

have you remembered to put a price value in the pet?

0

yes, i have done that

0

Can we see the ReplicatedStorage, please? And make sure the childrens of the Pets are revealed.

1 answer

instead of:

v.PetPrice.Text=
game.ReplicatedStorage:WaitForChild('Pets'):FindFirstChild(v.Name).Price.Value

do this:

v.PetPrice.Text=
game.ReplicatedStorage:WaitForChild('Pets'):FindFirstChild(v.Name.Price).Value

This discussion is preserved as it was. New answers, comments, and votes are closed.