So I have a gun script, and a main game script. When someone kills someone else with a gun script, I want the main game script to figure out who the killer was. How can I figure out who the killer is? Are there any built-in methods or events to help me figure out the killer?
Heres a way
InsertTag script -- make sure its in a localscript inside a Tool
local Player = game.Players.LocalPlayer function Died() local CT = Player.Character:FindFirstChild("Humanoid"):FindFirstChild("Creator_Tag") print(CT.Value .. " has killed " .. Player.Name) end function Hit() local Parent = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid") -- Where humanoid is located InsertTag(Parent) end function InsertTag(parent) local Creator_Tag = Instance.new("StringValue") Creator_Tag.Parent = parent Creator_Tag.Name = "Creator_Tag" Creator_Tag.Value = Player.Name end Bullet.Touched:connect(Hit) Player.Character:FindFirstChild("Humanoid").Died:connect(Died)
This was not tested so it may not work.