Hey guys, So, I'm fairly new to LUA scripting and would love some help.
So basically, I want to add a timer, and when the timer runs out the person with the object last, dies. Kind of like time bomb.
As I said, I'm really new to this, so I'd love a helping hand. :-)
There are events for Tool.Equipped:Connect()
You can start a timer in the script then access the player's humanoid and set the health below or equal to zero. Remember to also use Tool.Unequipped:Connect() or disconnect the event.
Put this inside the tool instance itself (not the part, the tool) as a normal script (not a local or module)
01 | local tool = script.Parent |
02 | local currentime = 0 -- Current Time (once it equals timend, it will make the player with it die) |
03 | local timend = 5 -- Time max (in seconds) |
04 |
05 | function toolEquipped() |
06 | begin() |
07 | end |
08 |
09 | tool.Equipped:connect(toolEquipped) |
10 | local db = 0 |
11 | function begin() |
12 | if db = = 0 then |
13 | db = 1 |
14 |
15 | function getHumanoid() |
This script however will not make anything die if it's not equipped by a player.
But I did make it so it will only do the counting only IF equipped by a humanoid/player.