Answered by
8 years ago Edited 8 years ago
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:
1 | script.Parent.Touched:connect( function (touched) |
2 | if touched.Parent.Humanoid then |
3 | touched.Parent.Humanoid:TakeDamage( 10 ) |
4 | if touched.Parent.Humanoid.Health = = 0 then |
5 | script.Parent.Parent.EXP = script.Parent.Parent.EXP + 1 |
If this helped you, please don't forget to accept the answer :)