How can I detect deaths caused from falling into the void?

I am creating a tool that allows the player to grab onto and throw other players. I’d like to create a system that gives you points if you throw a player into the world void. The problem is that I don’t exactly know how I could consistently detect when a player dies specifically from the void.

I’ve made a post similar to this several months ago: How do I record deaths from people dying in the void?
I wasn’t very familiar with scripting at the time, and most of what I tried either did not work or was very inconsistent.

Thank you! Please let me know if you need more information on this or anything.

(EDIT: Every player has a value stored on their Player object called “lastGrabbed”. When they are grabbed, the value changes to whoever last grabbed them. This is used to provide the points.)

When the player dies, get the y value of their HumanoidRootPart. If it’s below a threshold you can assume they died via falling into the void.

humanoid.Died:Connect(function()
	if humanoidRootPart.Position.Y < threshold then
		-- they died from void
	end
end)
2 Likes

They would have to make their own kill part if they’re talking about the default FallenPartDesroyHeight.
Because the RootPart should already be destroyed at that point.

When testing it works if they keep the humanoidRootPart variable outside of the Died connection because the instance was already stored beforehand.

game.Players.PlayerAdded:Connect(function(plr)
    local humanoid = plr.Character.Humanoid
	local threshold = -10

	humanoid.Died:Connect(function()
		local humanoidRootPart = plr.Character.HumanoidRootPart
		
		if humanoidRootPart.Position.Y > threshold then
			print("ded")
		end
	end)
end)

I’m guessing you were thinking of something like this.

1 Like

Just store the player’s HumanoidRootPart in a table on CharacterAdded. Don’t forgot to remove it on PlayerRemoving or else it will memory leak.

2 Likes
local voidHeight = workspace.FallenPartsDestroyHeight
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local hmr = character:WaitForChild("HumanoidRootPart")

humanoid.Died:Connect(function()
	if hmr.Position.Y <= voidHeight then
		print("Player died from falling into the void!")
	else
		print("Player died but did not fall into the void!")
	end
end)

You can make use of the “FallenPartsDestroyHeight” property of the workspace to determine the void depth (the Y co-ordinate at which parts are destroyed). This will work both as a server script or as a local script.

More info:
https://developer.roblox.com/api-reference/property/Workspace/FallenPartsDestroyHeight

You could also detect a change in the value of the “Position” property of the HMR instead, like this:

local voidHeight = workspace.FallenPartsDestroyHeight
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local hmr = character:WaitForChild("HumanoidRootPart")

hmr:GetPropertyChangedSignal("Position"):Connect(function()
	if hmr.Position.Y <= voidHeight then
		print("Player died from falling into the void!")
	else
		print("Player died but did not fall into the void!")
	end
end)
5 Likes

Not sure if that would work for you, or work anyways.

When the player falls into void, you die and the character’s body parts are instantly removed. You could check in your .Died function if you can find a Character’s body part, unless you have a script that removes parts on death, then that would probably not work well for you.

If it finds parts still when you die, add a wait() before the check.

Hope this helped.

1 Like