I am making a game which has a mechanic similar to the one found in carry people simulator where you can grab people and then throw them off the map for kills.
I’m having trouble with finding out how to record when you throw someone else off the map and gain kills from it.
I have leaderstats and all that, this is the only thing I am confused about.
The player dies in the void at a default height of -500 (unless you changed it). The easiest way to do this would be to increment a value on the leaderstats whenever the PrimaryPart of the player’s character reaches that height or lower.
I’ll try that for how I’ll make it check for deaths in the void.
Still though, how do I make it remember who actually threw you in the void? Cause obviously you could just jump in there without anyone actually throwing you in.
Whenever someone is thrown or otherwise picked up, you can add a tag to that player which stores the name of the person who threw them. That way when they die/fall in the void, you can check the tag to see who (if anyone) should be credited with the kill!
Get a variable and record the last dude who carry the person who fell off the map. And after he fell, you can detect his hp is 0. So basically use an if statement and if the guy hp is 0 then just increase the kills value for the last player who carried him.(aka the variable)
local function OnThrow(Char,CharKiller)
local recivedPoint = false
Char.Torso:GetPropertyChangedSignal("Velocity"):Connect(function()
if Torso.Position.Y >= -240 then
if Char.Humanoid.Health <= 0 and recivedPoint == false then
recivedPoint = true
-- add points to the Char killer
else
if Char.Humanoid:GetState() == Enum.HumanoidStateType.Landed then
recivedPoint = false
return
end
end
end
end)
end
I think another method is to use Instance | Documentation - Roblox Creator Hub on a value object inside the character. When the character dies and the model gets destroyed this event should run and hence possible for the person who threw the character to get rewarded.