so how would I get a player to gain exp when they kill another player? I understand how leaderstats work just not how the function would work.
The best way to create a function that does something upon a death is by using the .Died
event of a Humanoid. How this event works is that when a Humanoid dies, the function is carried out. To create a function that would give a player EXP once he killed another player, you'd do something like this:
script.Parent.Touched:connect(function(touched) --In this case the parent of the script is a tool if touched.Parent.Humanoid then --Script checks to see if it is a human touched.Parent.Humanoid:TakeDamage(10) if touched.Parent.Humanoid.Health == 0 then --If the opponent who was hit was killed then this will run script.Parent.Parent.EXP = script.Parent.Parent.EXP + 1 --Adds EXP end end end)
If this helped you, please don't forget to accept the answer :)