What am I indexing wrong in this script?

I am not able to figure out why I am indexing the HRP wrong in this script?

local Players = game:GetService("Players")

local LocalPlayer = game.Players.LocalPlayer

local Character = LocalPlayer.Character

local HRP = Character.HumanoidRootPart

The issue is this:

attempt to index nil with 'HumanoidRootPart'

that means the character has not loaded yet

local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
2 Likes