Why is it saying attempt to index nil with Humanoid Not Referenced Correctly?

I am highly sure this is supposed to work unless its an engine bug, this is located in a Local Script inside a Tool placed in the Starter Pack All help appreciated:

local ReplicatedStorage = game.ReplicatedStorage
local RunService = game:GetService("RunService")

local GunTool = script.Parent

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local mouse = player:GetMouse()

local ShootSound = GunTool.Shoot
local NoAmmoSound = GunTool.NoAmmo

local PlayerGui = player.PlayerGui
local Aim = PlayerGui["Main Screen"].Aim

local reloading = false
1 Like

Cant tell from your code. Maybe check to see what is assigned with the humanoid?
Code seems fine so far from what I can tell…

2 Likes

It was just a loading problem i had to put a wait()

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.