So, recently I've been working on creating my own NPC's and all that stuff...well anyways, my question to whoever is willing to help is: How do I find the player who killed the NPC? How would I be able to do this, and find the exact player who killed the NPC so that I can award them? (I want the player to be awarded gold when the NPC is killed.)
Gold Stat: game.Players.Player.leaderstats.Gold
Heres what I have so far in the sword I made:
Plr=game.Players.LocalPlayer
Mouse=Plr:GetMouse()
Swinging=false
ReadyToSwing=true
SwingTime=.75
---Functions---
function Swing()
Swinging=true
ReadyToSwing=false
script.Parent.Parent.GripForward=Vector3.new(1,0,0)
script.Parent.Parent.GripPos=Vector3.new(0,0,-1)
script.Parent.Parent.GripRight=Vector3.new(0,1,0)
script.Parent.Parent.GripUp=Vector3.new(0,0,0)
wait(SwingTime)
script.Parent.Parent.GripForward=Vector3.new(1,0,0)
script.Parent.Parent.GripPos=Vector3.new(0,0,-1.5)
script.Parent.Parent.GripRight=Vector3.new(0,-1,0)
script.Parent.Parent.GripUp=Vector3.new(0,0,1)
Swinging=false
wait(1)
ReadyToSwing=true
end
script.Parent.Touched:connect(function(Part)
if Part.Parent:FindFirstChild("Humanoid") and Swinging==true then
Plr=Part.Parent
PlrName=Plr.Name
if not game.Players:FindFirstChild(PlrName) or game.Players:FindFirstChild(PlrName).Character~=Plr then
Plr.Humanoid:TakeDamage(math.random(5,8)/2)
end
end
end)
script.Parent.Parent.Equipped:connect(function()
Mouse.Button1Down:connect(function()
if Swinging==false and ReadyToSwing==true then
Swing()
end
end)
end)
If anyone could possibly help me, thank you in advance.
(If any more information is needed, please leave a comment.)

2 comments
Yes, this works :D. Thanks for the response. Thumbs up :P
Thanks. More people should ask questions like you do. Your question was very thorough and easy to read, and allowed me to give you an answer quickly and easily.