What do i want to achieve?
I want to make a script that kills user’s like arsenal when you hit the backspace button
What is the issue?
The issue is Workspace.Part.User:3: attempt to index nil with ‘Character’
What solutions have you tried so far?
I tried looking for similar post like this but I could not find it.
local UserInputService = game:GetService(“UserInputService”)
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded
local Humanoid = char:WaitForChild(“Humanoid”)
if input.KeyCode == Enum.KeyCode.Q then
Humanoid.Health = 0
You want to kill the player from the server side, so the other players will see it.
First put a RemoteEvent named “PlayerReset” in game.ReplicatedStorage.
Then add these scripts:
LocalScript in game.StarterPlayer.StarterPlayerScripts:
local uis = game:GetService("UserInputService")
local event = game:GetService("ReplicatedStorage"):WaitForChild("PlayerReset")
if (input.KeyCode == Enum.KeyCode.Q and not gpe) then
Regular Script in game.ServerScriptService:
local event = game:GetService("ReplicatedStorage").PlayerReset
local humanoid = player.Character and player.Character:FindFirstChild("Humanoid")
if (humanoid) then
humanoid.Health = 0