I'm trying to get the Character from the Player in a LocalScript so I can get the HumanoidRootPart to teleport them, but every time I try to get the HRP, it just errors: attempt to index nil with 'character' (on line 2)
The code:
local Player = game.Players.LocalPlayer local HRP = Player.Character.HumanoidRootPart print(HRP.Position)
This script should go in a localscript in StarterPlayer< StarterPlayerScripts
Code:
local Player = game:WaitForChild("Players").LocalPlayer local Character = Player.CharacterAdded:Connect(function(char) local HRP = Player.Character:WaitForChild("HumanoidRootPart") if Player.Character then print(HRP.Position) end end)
it's very straight actually, "attempt to index nil with 'character'" so there player = nil
why? Players.LocalPlayer can be used only inside a local script and CAN NOT be used inside a server script and so it will return nil, this is probably your problem