Honestly, I have no clue how
✓ ANSWER ACCEPTED
How do I make a tool where you gain a leaderstat?
1 answer
✓ Accepted answer
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:
local Player = game.Players.LocalPlayer -- Local Player
local Tool = script.Parent -- Tool
Tool.Equipped:connect(function() -- Equipped event for tool
local LeaderStats = Instance.new("IntValue", Player) -- Inserts a value called leaderstats into the player
LeaderStats.Name = "leaderstats"
local SecondsHeld = Instance.new("IntValue", LeaderStats) -- Creates a value called seconds held inside of leaderstats
SecondsHeld.Name = "seconds held"
coroutine.resume(coroutine.create(function() -- starts a new thread
while wait(1) do -- every second seconds held goes up by 1
SecondsHeld.Value = SecondsHeld.Value+1
end
end))
end)
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
:) thanks