Attempt to index nil with 'Parent' on Block System

Hello there,

So I’ve come into an issue that I’m not quite sure how to resolve. I am trying to create a sword system and currently working on the blocking feature. The issue I’m facing is that I have created a local function to get the targets block value as shown below:

local TargetIsBlocking = targetHumanoid.Parent:WaitForChild("Block").Value

Now the issue I am facing is that I get this error:


This error comes up and not quite sure how to fix this.

I have also found that sometimes it is picking up the value as I have created a if statement to see if its either true or false as shown here:

if TargetIsBlocking == true then
	print("isBlocking")
	else
	print("NotBlocking")
end

This is my current output:


You can see that it is creating the error but is also managing to check if the player is blocking.

Line 32 where the error says it is at is the local TargetIsBlocking. Any help would be much appreciated.

Check the targetHumanoid instead, it might be an issue with how you actually get the targetHumanoid

Can you send that line and the surrounding lines of code, for a bit of context? I don’t think the code you sent to far is where the error is coming from.

Hi all,

After restarting Studio, this has seemed to fix the issue. The print statement is working and the error is no longer occurring. I think it was just a studio bug.

1 Like

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