Quest system nil indexing

Hello! I wanted to know why this system for my quests returns indexing nil for the playerAmount. This code is in a local script in Starter Gui.

while true do
	local Req1 = script.Parent.Parent.Parent:WaitForChild("QuestREQ")
	local Req2 = script.Parent.Parent.Parent:WaitForChild("QuestREQ2")
	local Prompt = script.Parent.Parent.Parent:WaitForChild("Prompt")
	local playerAmount = game.Players.LocalPlayer.items:FindFirstChild(Req1.Value)
	
	script.Parent.Text = Prompt.Value.." "..playerAmount.Value
	wait(1)
	end

If you’re not getting errors it’s probably because you haven’t set any value for Req1

Oh, sorry, should have specified the error is the nil, and Req1 is specified.

Can you copy and paste the error?

Players.SloppyBanana225.PlayerGui.Quests.Frame.TextLabel.LocalScript:7: attempt to index nil with ‘Value’ - Client - LocalScript:7

09:10:14.155 Stack Begin - Studio
09:10:14.155 Script ‘Players.SloppyBanana225.PlayerGui.Quests.Frame.TextLabel.LocalScript’, Line 7 - Studio - LocalScript:7
09:10:14.155 Stack End - Studio

Replace FindFirstChild(Req1.Value) with FindFirstChild(Req1) and see if it works out.

What is Req1? Is it a StringValue? Why not just put the actual name of the value that you are trying to display on your textlabel?

1 Like

No, I wrote the value of that string to be an item for the players inventory.

it’s a random quest system so I have to transport information via strings. And Req1 is a number value for the progress bar.

Okay. Just confirming though, is there actually a Value Instance in the items folder (I assume)? A StringValue, NumberValue etc.?

1 Like

Yes, there is. And they are spelled right, they are under the player in game.Players.

1 Like

When you mean they, are you talking about the items folder?
(Sorry for asking too many questions)

1 Like

the items in the folder, so it reads them right in the code, but it reads their value as nil.

1 Like

Okay.
Try using this code:

local Req1 = script.Parent.Parent.Parent:WaitForChild("QuestREQ")
local Req2 = script.Parent.Parent.Parent:WaitForChild("QuestREQ2")
local Prompt = script.Parent.Parent.Parent:WaitForChild("Prompt")

local player = game.Players.LocalPlayer
local playerAmount = player.items:WaitForChild(tostring(Req2.Value))
local TextLabel = script.Parent

TextLabel.Text = Prompt.Value.." "..playerAmount.Value

playerAmount:GetPropertyChangedSignal("Value"):Connect(function()
	TextLabel.Text = Prompt.Value.." "..playerAmount.Value
end)
1 Like

It worked more or less, it didn’t transmit the actual quest, only the players quantity

1 Like

So no errors popping up anymore?

1 Like

Ehh, nope, hang on though I think might work.

script.Parent.MouseButton1Click:Connect(function()
	local Req1 = script.Parent.Parent.Parent:WaitForChild("QuestREQ")
	local Req2 = script.Parent.Parent.Parent:WaitForChild("QuestREQ2")
	local Prompt = script.Parent.Parent.Parent:WaitForChild("Prompt")
	local Type = script.Parent.Parent.Parent:WaitForChild("Type")
	local Who = script.Parent.Parent.Parent:WaitForChild("Who")
	local playerVal = game.Players.LocalPlayer.items:FindFirstChild(Req2.Value)
	
	Prompt.Value = Type.Value.." "..Req1.Value.." "..Req2.Value.." "..Who.Value.." "..playerVal.Value.."/"..Req1.Value
		script.Parent.Parent.Visible = false
		end)

Now this is my code in the accept button, but how would I make that last bit playerVal, load when the player was updated? It now “works” though.

Sorry, what do you mean? You want what to load when a player was update? Could you please explain again?

1 Like

Well, I meant the playerVal, sorry. But it seems to load now, I’ll contact you if it has more issues.

1 Like