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