Instant death tool

i made a script that kills the player when it is activated

local tool = script.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

tool.Activated:Connect(function()
	humanoid:TakeDamage(100)
end)

i don’t understand why it isn’t working

This doesn’t seem to make sense, you can just condense this to

local character = tool.Parent

Also, can you describe what you mean by “not working”?

well when the tool is activated it’s supposed to make the humanoid take damage

you could try

script.parent.activated:Connect(function(hit)
local char = workspace:findfirstchild(hit.Name)
char.Humanoid.Health = 0
end)

I know, but what’s the issue? Is the script not running? Is the player not fullying dying?

yeah its not dying like i made the script to do

You can insert math.huge into the Humanoid:TakeDamage parameters or just set the humanoid health to 0 like @Callum_Cloth suggested:

humanoid:TakeDamage(math.huge)

you can by doing

char.humanoid.Health = char.humanoid.Health - number

You can

With Humanoid.Health you can just set its health

Humanoid:TakeDamage() is a function for Humanoids to take Damage, the only difference is that you cant add with Humanoid:TakeDamage()

alright i’ll see if that works

unfortunately that didn’t as well

Did you try this yet?


script.parent.activated:Connect(function(hit)
local char = workspace:findfirstchild(hit.Name)
char.Humanoid.Health = 0
end)

but that in a normal script in the tool

is there any errors in output?

15:45:33.640 Script ‘Players.H2nad.Backpack.Instant Death.Script’, Line 3 - Studio - Script:3
15:45:33.640 Stack End - Studio

not seeing anything out of the ordinary

can i see whats the current script you are using?

local tool = script.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")

local function instantkill ()
	humanoid:TakeDamage(100)
end

tool.Activated:Connect(instantkill)

is the script context local ? also have you tried this script yet

script.parent.activated:Connect(function(hit)
local char = workspace:findfirstchild(hit.Name)
char.Humanoid.Health = 0
end)

Also. The code you are running at the beginning, It will only run once, Are you sure you have access to the Player? And are you sure it isnt nil?

yes, that didn’t work either :((

try adding a print under the player (print the player variable)

see if its returning nil or not