Script can't find a billboard gui in the player's head

Script can’t find a billboard gui in the player’s head
image
The script is not a local script and it is in server script service, the script that creates the billboard gui is in StarterCharacterScripts
image

However, it all works in studio, the billboard gui gets found and does what I want it to do
image

But, if I go into the actual game, the billboard gui does not change
image
And I get this error,


The lines where the error is found are
image
And the path to the nametag is correct.

I have tried every solution I could find so if someone here could help me that would be really helpful!

I can provide more info if needed for a while after this post, but soon I will have to go and wont be active for a day or so.

1 Like
game.Players.PlayerAdded:Connect(function(plr)
   plr.CharacterAdded:Connect(function(char)
      if MPS:UserOwnGamePassAsync(plr.UserID, 161641804) then
         print(plr.Name .. " owns VIP gamepass.")
         local head = char:WaitForChild("Head")
         if head then 
            local button = head.NameTag.NameTag
         end
      end
   end)
end)

Character or Character Head isn’t exist yet when the script run.
That why you got an “Attempt to index nil with ‘Head’”

1 Like


I got this error

1 Like

Try to use this:

game.Players.PlayerAdded:Connect(function(plr)
if MPS:UserOwnsGamePassAsync(plr.UserId, 161641804) then
plr.CharacterAdded:Connect(function(chr)
       local head = chr:WaitForChild("Head")
       local button = head:WaitForChild("NameTag"):WaitForChild("NameTag")
      end
   end)
end)
1 Like
game.Players.PlayerAdded:Connect(function(plr)
   plr.CharacterAdded:Connect(function(char)
      if MPS:UserOwnGamePassAsync(plr.UserId, 161641804) then
         print(plr.Name .. " owns VIP gamepass.")
         local head = char:WaitForChild("Head")
         if head then 
            local button = head.NameTag.NameTag
         end
      end
   end)
end)
1 Like

Thank you! I used this and replaced UserOwnGamePassAsync() with UserOwnsGamePassAsync() and it’s all working now!

1 Like

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