[SOLVED] "Humanoid is not a valid member of Model "Workspace.kdopdaux1803""

Hello guys, i found another issue.

This time, it’s different because the Humanoid is not a valid member of the Character.

LocalScript:

local KeyCode = Enum.KeyCode
local RKeyCode = KeyCode.R or require(KeyCode.R)
KeyCode = KeyCode.R

script.Parent.MouseButton1Click:connect(function()
	game.Players.LocalPlayer.Character.Humanoid.Health = 0
end)

if RKeyCode then
	game.Players.LocalPlayer.Character.Humanoid.Health = 0 -- ISSUE (Line 10)
end
If you want to find any images, there's gonna be 0 images. Why ? Because it already says it on the title.

Couldn’t find any images because it already says it on the title.

So yeah any help is appreciated.

1 Like

the problem was the player was loading and the character doesn’t have a humanoid yet

task.wait(10)

if RKeyCode then
	game.Players.LocalPlayer.Character.Humanoid.Health = 0 -- ISSUE (Line 10)
end
1 Like

Write this at the top of your code

game:GetService("Players").LocalPlayer.CharacterAdded:Wait()

10 seconds seems long…

And it killed me before i touched the command “R”.

1 Like

Wait for the Humanoid to actually load

local Character = game:GetService(“Players”).LocalPlayer.Character or game:GetService(“Players”).LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)

local KeyCode = Enum.KeyCode
local RKeyCode = KeyCode.R or require(KeyCode.R)
KeyCode = KeyCode.R

script.Parent.MouseButton1Click:connect(function()
Humanoid.Health = 0
end)

if RKeyCode then
Humanoid.Health = 0 -- ISSUE (Line 10)
end

It maked my health to 0 instead.

Edit: It was kinda inappropriate, before.

The reason as to why it makes your health 0 is because you haven’t made it so that once r key is pressed it will run, what you put is that once the variable is true it will run rather than the key is pressed, I have changed it so once the R key is pressed health is set to 0.

local UIS = game:GetService(“UserInputService”)
local Character = game:GetService(“Players”).LocalPlayer.Character or game:GetService(“Players”).LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild(“Humanoid”)

local KeyCode = Enum.KeyCode
local RKeyCode = KeyCode.R

script.Parent.MouseButton1Click:connect(function()
Humanoid.Health = 0
end)

UIS.InputBegan:Connect(function(input)
if input.KeyCode == RKeyCode then
Humanoid.Health = 0 -- ISSUE (Line 10)
end
end)
1 Like

Thanks it worked !

@BirdieI90 Thanks to try to help me.
@msix29 Thanks to try to help me.

Also, the 1st 3 lines has an error:

It’s actually:

local UIS = game:GetService("UserInputService")
local Character = game:GetService("Players").LocalPlayer.Character or game:GetService("Players").LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

Instead.

1 Like