Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how can i add 1 "Muscle" to my leaderstats by clicking with my tool?

Asked by 3 years ago
Edited 3 years ago

my leade3rstats are called "Muscle" i need it for a simulator i made saving leaderstats so all i need is to make tool and Purchaseable tools please help me :D so i would apresiate help on purchasable tools :D

current code

local Player = game.Players.LocalPlayer local Stats = Player:WaitForChild("leaderstats")
local Mucsle = Stats:WaitForChild("Muscle")

local Debounce = false -- this prevent from spamming the button! Button.MouseButton1Click:Connect(function() if Debounce == false then Debounce = true

    Muscle.Value = Muscle.Value + 1

    wait(1) -- this is the amount of secounds you should wait before getting more money!

      Debounce = false
end 

end)

0
i really need help spideyweartideys 7 — 3y
0
nah surviarlTheJefkillre 55 — 3y
0
I think you might want to look the API for the Activated event (https://developer.roblox.com/en-us/api-reference/event/Tool/Activated) which tools have. It triggers if a player clicks while having the tool equipped. Dfzoz 489 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Hey, no problem man. Heres some code to munch on.

script.Parent.Activated:Connect(function() 
local plr = game.Players:FindFirstChild(script.Parent.Parent.Name)
if plr then
local stats = plr:WaitForChild("leaderstats")
local theStat = stats:WaitForChild("name_of_your_stat")
theStat.Value = theStat.Value + 1
end
end)
0
use it from a server script btw Syntax155 30 — 3y
0
is there anyway i can add 1 second of time in between each click? spideyweartideys 7 — 3y
0
and my saving data isnt workin now :/ spideyweartideys 7 — 3y
Ad

Answer this question