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
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)
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)
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