Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

2 comments

0

what script is this code in server or local?

0

server

1 answer

✓ Accepted answer

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)

2 comments

0

idk how it worked, even if i had another script to change value, but it worked

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

This discussion is preserved as it was. New answers, comments, and votes are closed.