Character index nil

Some basic stuff problems but I seriously cant figure out why it shows me “character index nil”.

Here the code

local Player = game.Players.LocalPlayer
local hmrp = Player.Character:WaitForChild("HumanoidRootPart")

Thanks for helping and I wish you all best!

Try:

local Character = Player.Character or Player.CharacterAdded:Wait()
local hmrp = Character:WaitForChild("HumanoidRootPart")

What this means is that the character is nil, I would do

local Character = Player.Character or Player.CharacterAdded:Wait()

Or what you could do is have this on the first line of code.

wait(math.random())

This way when the character is indexed it wont be nil because the character will be ingame

The issue was that I put the script in the wrong place.

But now my print(Vector…) doesnt seem work

You cant access player character through a server script. Through you could do try using ‘chr = script.Parent’ and printing it out like ‘print(chr.Name)’ and see if it works.

1 Like

The issue is away but now my “print” doesnt work,

does it print out your character name or it just gives you an error?

1 Like

It just prints nothing. Look, I put the script the script in StarterPlayerScripts and it seems work there. But it doesnt seem working to print my Vector Position after I got no error.

Oh thanks I just realize its a script instead of a local script