Why can't I use children of a players character?

Hello, for some reason, every time I try to use a child of a player’s character, it says “tried to index nil with (bodypart)”. Here is my script:

local UIS = game:GetService("UserInputService")

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

local lBolt = game:GetService("ReplicatedStorage").Bolt

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.F then
		local bolt = lBolt:Clone()
		bolt.Parent = workspace
		bolt.Position = character.LeftHand.Position
	end
end)

Your character most likely isn’t loaded yet, try:
local character = player.Character or player.CharacterAdded:Wait()

Edit: I made a spelling mistake lol

1 Like

you need to yield for character by doing local character = player.Character or player.CharacterAdded:Wait() because the issue is that the character is nil (not loaded yet) when you try to index it.

1 Like