Attempt to index nil with "CharacterAdded"

I am trying to make a script for NPC to look for player. In theory script should create a raycast from NPCs head towards the player’s humanoid root part, but it gives this error.
image
I tried to fix problem myself but that just does not work. Here is my script:
image
Any ideas on how to possibly fix the issue?

LocalPlayer doesn’t exist on server.

Wait, im actually so dumb, I put that code in a regular script, bruh. I’ll try it with local now.

Well, now it does not give any error, but the output is clear, without any changes (which is not supposed to be like that)

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