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.
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
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)
@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")