Attempt to index nil with 'Value'

Hi, so I have the error attempt to index nil with 'Value' in a local script in StarterGUI:

for _,v in pairs(workspace.Checkpoints:GetChildren()) do
	v.Touched:Connect(function(hit)
		if hit.Parent == player.Character then
			if player.PlayerGui.SpeedRun.TimerHolder.Visible == true then
				if v.Name == "20" then

					if tag.Value == "Easy" then --ERROR HERE

						game.StarterGui:SetCore("ChatMakeSystemMessage", {
							Text = "You have speedrunned the easy section in " ..timer.TextLabel.Text.. "! Good job!",
							Font = Enum.Font.SourceSansBold,
							Color = BrickColor.new("Sea green").Color
						})
						endTimer()
						exit.Visible = false
						stagetrans.Enabled = true
						timer.Visible = false
						skipstage.Enabled = true
					elseif tag.Value ~= "Easy" then
						return
					end

--more code here that's not relevant

I made the line easy to see. I have the value made on a server script in serverscriptservice. I don’t know whats happening and would appreciate anyone who would help me. Thanks!

It’s because you didn’t define the tag variable.

The error is really in the line you wrote the comment? In if v.Name == 20 then you’re not trying to index anything with value, as DargoA said, the error might be in the following line if tag.Value == "Easy then where you’re trying to index tag with value but the tag variable is not included in the script you wrote in the post.

oh yeah thats what i meant. Yeah the error Is there and i defined the tag variable. It is not the full script the tag variable is defined at the start of the script.

If you did define the variable then somehow when you’re checking

if tag.Value == "Easy" then

the tag variable gets nil, check in other scripts if you really defined it and if any of them sets the tag variable to nil.

Fixed it by just changing the variable from :FindFirstChild() to :WaitForChild()

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