The code below goes into the enemies, it gives the killer gold and xp. But I don't know how to make it know who killed it.
local gold = script.Parent.Config.Gold.Value local exp = script.Parent.Config.XP.Value local Humanoid = script.Parent.Humanoid function PwntX_X() local tag = Humanoid:findFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then local Leaderstats = tag.Value:findFirstChild("leaderstats") if Leaderstats ~= nil then Leaderstats.Gold.Value = Leaderstats.Gold.Value + gold wait(0.1) script:remove() end end end end Humanoid.Died:connect(PwntX_X)
This script is the damage script in the handle of the weapon used to kill the victim. If you know how to write it so it connects with the gold/exp script I would be very grateful.
dmg = script.dmg.Value function touch(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") hit.Parent:FindFirstChild("Humanoid").Health = hit.Parent:FindFirstChild("Humanoid").Health - dmg script.Disabled = true end script.Parent.Touched:connect(touch)
And the following script is something I got from the roblox paintball gun paintball script. I tried putting it inside the damage script and it didn't work.
function tagHumanoid(humanoid) -- todo: make tag expire local tag = script.Parent:findFirstChild("creator") if tag ~= nil then local new_tag = tag:clone() new_tag.Parent = humanoid end end function untagHumanoid(humanoid) if humanoid ~= nil then local tag = humanoid:findFirstChild("creator") if tag ~= nil then tag.Parent = nil end end end