Can't find problem in short, broken script

This is a script to have a NPC hand different items depending on the dialog chosen.
When I run it, it gives this error :Head is not a valid member of Model “Workspace.Uwe Koskinen” (Uwe koskinen being the name of the npc).
I am sure it is not a typo and Head is properly named in the workspace, but I can’t seem to solve the issue.
It had been fine before until I added 4 more options to select, but I don’t understand what has changed.

local dialog = workspace["Uwe Koskinen"].Head.Dialog
local DialogChoice2 = workspace["Uwe Koskinen"].Head.Dialog.DialogChoice2
workspace["Uwe Koskinen"]:WaitForChild("Head")
dialog.DialogChoiceSelected:Connect(function(plr, choice)
	if choice == DialogChoice2 then
		game.ReplicatedStorage:WaitForChild("GiveGear"):FireServer()
	elseif choice == workspace["Uwe Koskinen"].Head.Dialog.DialogChoice1 then
		game.ReplicatedStorage:WaitForChild("GiveGear1"):FireServer()
	elseif choice == workspace["Uwe Koskinen"].Head.Dialog.DialogChoice6 then
			game.ReplicatedStorage:WaitForChild("GiveGear2"):FireServer()
	elseif choice == workspace["Uwe Koskinen"].Head.Dialog.DialogChoice4.DialogChoice7 then
			game.ReplicatedStorage:WaitForChild("GiveGear3"):FireServer()
	elseif choice == workspace["Uwe Koskinen"].Head.Dialog.DialogChoice4.DialogChoice8 then
			game.ReplicatedStorage:WaitForChild("GiveGear4"):FireServer()
	elseif choice == workspace["Uwe Koskinen"].Head.Dialog.DialogChoice4.DialogChoice9 then
			game.ReplicatedStorage:WaitForChild("GiveGear5"):FireServer()
	end
end)

Which line is giving you an error? You might want to put the WaitForChild line at the start before you call the variables.

1 Like

Put your WaitForChild("Head") in the very first line.
You haven’t done that but are searching for something in the head in the first 2 lines before you run that line.

Thanks for your help. Silly me.

1 Like

Give the Solution to @Overseerzed since they mentioned it first, I just elaborated on what they said.

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