--I keep getting this error and I don't get what's happening. All I know is that its in this line of code.
` local HumanoidRootPart = NPC:FindFirstChild("HumanoidRootPart") **local ProximityPrompt = HumanoidRootPart:FindFirstChild("ProximityPrompt")** if HumanoidRootPart and ProximityPrompt then ProximityPrompt.ObjectText = NPC.Name ProximityPrompt.ActionText = "Talk to".. NPC.Name `
--script surrounded with '**' is the one not working.
Usually "Attempt to index nil" happens if something hasn't loaded in yet, Maybe try changing
:FindFirstChild()
to
:WaitForChild()
WaitForChild should be self-explanatory, It waits for a child with said name to load in. FindFirstChild will find the first child with said name, if there's none. It will return "Nil"
I also realised you've not told the script what "NPC" refers to, so that also may be why it's returning nil.
Try making a variable for that as well.
local NPC = game.Workspace:WaitForChild(" ") --Insert NPC Name here. local HumanoidRootPart = NPC:WaitForChild("HumanoidRootPart") local ProximityPrompt = HumanoidRootPart:WaitForChild("ProximityPrompt")
Hopefully one of these answers helped.