I don't know what the use of this would be, but you just create a leaderstats value under the player when a tool is equipped
Let's say you have a tool called sword in StarterPack, the following LocalScript would add leaderstats to the player if put inside of the tool:
01 | local Player = game.Players.LocalPlayer |
02 | local Tool = script.Parent |
04 | Tool.Equipped:connect( function () |
05 | local LeaderStats = Instance.new( "IntValue" , Player) |
06 | LeaderStats.Name = "leaderstats" |
07 | local SecondsHeld = Instance.new( "IntValue" , LeaderStats) |
08 | SecondsHeld.Name = "seconds held" |
10 | coroutine.resume(coroutine.create( function () |
12 | SecondsHeld.Value = SecondsHeld.Value+ 1 |
I'm not sure if creating a leaderstats from the client replicates to the server, so I would not use this script without RemoteEvents or RemoteFunctions.