HumanoidRootPart is not a member of Model error

I keep getting an error saying that HumanoidRootPart is not a member of Model. I believe I have
initialized everything correctly, so I am not sure why I am getting this error.

local player = game:GetService("Players").LocalPlayer

local tweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

local hammer = script.Parent

local r = Random.new()

local character

if not player.character then

print("waiting for character")

player.CharacterAdded:wait()

character = player.Character

else

character = player.Character

end

local light1 = workspace.Light1

local light2 = workspace.Light2

local light3 = workspace.Light3

local start1 = {Position = light1.Position}

local end1 = {Position = character.HumanoidRootPart.Position - Vector3.new(0, 0, r:NextInteger(5,10))} -- This is where the error is being thrown

Idk why there is an error but cant you just do:

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

EDIT: Maybe this script runs before the actual character has spawned try adding a wait

Edit2: Nvm, Because your script is waiting for the character, Sorry i can’t help you. I’m new to scripting so.

2 Likes

Your solution worked. I added wait() before the beginning of that line.

1 Like

Ah i see, No problem!
I don’t really know why that fixed it but i’m glad it did.

1 Like

That’s that magic of programming lol. Sometimes you just gotta play with stuff and it will end up working.

Yeah, Programming can be confusing :stuck_out_tongue:

Anyways, Merry christmas!
I hope you have a nice day.

1 Like