Like I just pressed 1 to open the tool and I want something to happen
if Tool.Open = true maybe?
You would use the Equipped event.
If the script inside was a local script,
1 | script.Parent.Equipped:connect( function () -- Runs the anonymous function when equipped |
2 |
3 | game.Players.LocalPlayer.Character:BreakJoints() -- Kills the player who equipped the tool |
4 |
5 | end ) |
01 | Tool = script.Parent |
02 |
03 | function Equip() |
04 | --Write your code here |
05 | end |
06 |
07 | function Unequip() |
08 | --Write your code here |
09 | end |
10 |
11 | Tool.Equipped:connect(Equip) |
12 | Tool.Unequipped:connect(Unequip) |
Don't forget your Handle in the tool! And if you are using "HopperBin" it's:
1 | Tool.Selected:connect(Equip) |
2 | Tool.Deselected:connect(Unequip) |