I’m trying to make a script so that you die when you press R, but I get an error. This is the error
[Players.Bliksem18.PlayerScripts.RToReset:7 attempt to index nil with ‘Humanoid’]
And this is the script I use. It is in a LocalScript.
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character
UIS.InputBegan:Connect(function(input,gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.R then
character.Humanoid.Health = 0
end
end)
I am very new to scripting and Roblox developing. It would be great if someone could help me.