Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Humanoid is not a valid member of model?

Asked by 10 days ago
Edited 10 days ago

Hey I am currently making a first person script and I am having a problem, the problem is is that it says "18:18:31.139 - Humanoid is not a valid member of Model", I honestly dont know what is happening. Please help.

local player = game.Players.LocalPlayer
local char = player.Character
local hum = char.Humanoid
local cam = workspace.CurrentCamera

cam.FieldOfView = 100
hum.CameraOffset = Vector3.new(0,0,-1)

for childIndex, child in pairs(char:GetChildren()) do
    if child:IsA("BasePart") and child.Name ~= "Head" then
        child:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
            child.LocalTransparencyModifier = child.Transparency
        end)
        child.LocalTransparencyModifier = child.Transparency
    end
end

Error: 18:18:31.139 - Humanoid is not a valid member of Model

1 answer

Log in to vote
2
Answered by
skvyy 153
10 days ago
Edited 10 days ago

The issue here is that you are getting the Humanoid before it is loaded into the game.

A better solution would be:

-- Variables:
local Camera = workspace.CurrentCamera

local Plr = game.Players.LocalPlayer
local Char = Plr.Character or Plr.CharacterAdded:Wait()
local Hum = Char:WaitForChild('Humanoid')

I hope this helps!

Please accept this answer if it helps you!

Ad

Answer this question