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)