- What do you want to achieve?
I want to detect a target who got killed by a killer & the killer who killed the target for my upcoming game.
- What is the issue?
I’m unable to know what to use in this situation & might need some help.
I want to detect a target who got killed by a killer & the killer who killed the target for my upcoming game.
I’m unable to know what to use in this situation & might need some help.
In your kill script you will need to add these few lines
local tag = Instance.new("ObjectValue")
tag.Name = "creator"
tag.Parent = playerTakingDamage.Character.Humanoid
tag.Value = attakingPlayer
Debris:AddItem(tag, 0.5)
You will also need:
local Debris = game:GetService("Debris")
Last thing:
A script in StarterCharacterScripts
local char = script.Parent
char.Humanoid.Died:Connect(function()
if char.Humanoid:FindFirstChild("creator") then
local killedBy = char.Humanoid:FindFirstChild("creator").Value
end
end)
Maybe check out this video I made about making a reputation system like from Super Power Training Simulator we had to detect who killed the player:
tool:
tool.Activated:Connect(function()
tool.ToolParts.HitPart.Touched:Connect(function(touch)
local thisPlayer = game.Players:GetPlayerFromCharacter(tool.Parent)
local Tagged = Instance.new("ObjectValue")
Tagged.Name = "creator"
Tagged.Value = thisPlayer
Tagged.Parent = touch.Parent.Humanoid
end)
end)
see who killed him(inside the SSS) not local script ofc
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
if humanoid:FindFirstChild("creator") then
local FindPlayer = humanoid:FindFirstChild("creator").Value
print("yes)
end
end)
end)
end)