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

Why my script for showing value of clicks in console doesn't work? [solved]

Asked by 3 years ago
Edited 3 years ago

I have a problem with leaderstats value of clicks.

local Players = game:GetService("Players")


local clickDetector = script.Parent
clickDetector.MouseClick:Connect(function(plr)
    local leaderstats = plr.leaderstats
    local clicks = leaderstats.Clicks
    print("your click value is "..clicks.Value)
end)

For example, if i have 10 clicks, it keep show 0 clicks in console. How do i need to fix that?

0
what script is this code in server or local? Xx0966xX 41 — 3y
0
server dmitry120199 2 — 3y

1 answer

Log in to vote
0
Answered by
LeHelary 142
3 years ago

You are connecting to the MouseClick event, and you are printing the value of clicks.. but you're not updating that value.

local Players = game:GetService("Players")


local clickDetector = script.Parent
clickDetector.MouseClick:Connect(function(plr)
    local clicks = plr.leaderstats.Clicks
    clicks.Value = clicks.Value + 1
    print("your click value is "..clicks.Value)
end)
0
idk how it worked, even if i had another script to change value, but it worked dmitry120199 2 — 3y
0
it would make no sense to have another script to change the value since you are already getting the click event here, but if you had another script to change the value then it's either broken or it's a LocalScript LeHelary 142 — 3y
Ad

Answer this question