Display on screen exact amount

guys cuz i wrote this code that gives you clicks if you have a gamepass which works good

if you want to see

local Event = game.ReplicatedStorage:WaitForChild("Click")

local MarketplaceService = game:GetService("MarketplaceService")

local passID = 897790611



Event.OnServerEvent:Connect(function(plr)
	local clicks = plr.leaderstats.clicks
	local upgrade = plr.leaderstats.Upgrades
	local rebirth = plr.leaderstats.Rebirths
	
	local hasPass = false

	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(plr.UserId, passID)
	end)
	
	if not success then
		clicks.Value += upgrade.Value * (rebirth.Value + 1)
		print("click without gamepass")
	end
	if hasPass then
		clicks.Value += (upgrade.Value * (rebirth.Value + 1)) * 2
		print("click with gamepass")
	end
	
end)

but i also have a code which displays how much click you got and i did it like this

and i dont know how can i make it display the same number like in the script above without checking if a player has a gamepass or not is there anyways to store the number somewhere and display it in this script? this one is in StarterGui

amount.Text = 0 + upgrade.Value * (rebirth.Value + 1)

cant you just do this?

local players = game:GetService("Players")
local plr = players.LocalPlayer

local clicks = plr.leaderstats.clicks

local amount = -- the location of your text label

amount.Text = tostring(clicks.Value)
clicks:GetPropertyChangedSignal("Value"):Connect(function()
    amount.Text = tostring(clicks.Value)
end)
2 Likes

it adds up at first its normal value like 2 and then its showing 4, 6, 8 and so on

edit: actually it shows my amount of clicks, i just want to display how much i got

1 Like
local Player = game:GetService("Players").LocalPlayer
local Clicks = plr.leaderstats.clicks

local AmountLabel = -- your label

local lastValue = Clicks.Value

Clicks:GetPropertyChangedSignal("Value"):Connect(function()
    local newValue = Clicks.Value
    local gainedClicks = newValue - lastValue
    AmountLabel.Text = newValue
    print(`Gained {gainedClicks}`)
    -- do something with `gainedClicks`
    lastValue = newValue -- Update last value
end)

You can also check whether it was actually a gain or a loss.

if gainedClicks > 0 then 

end

i created intValue in replicated storage and named it clickValue and when you click you change the value of it and then display it, thats what i meant but still the first value displays 0 - , -

local clickvalue = game.ReplicatedStorage:WaitForChild("ClickValue")
		
		amount.Text = tostring(clickvalue.Value)
if not success then
		clicks.Value += upgrade.Value * (rebirth.Value + 1)
		clicksvalue.Value = upgrade.Value * (rebirth.Value + 1)
		print("click without gamepass")
	end

is there a way to make the value first change in IntValue and then display it?

i tired to first fire the event and then display it but that doesnt work

ohh, sorry for the misunderstanding :sweat_smile:

its okay dont worry people make mistakes no need to apologize

1 Like

use what I gave you, it would work ideally and that’s all you really need