How to make a script aways check and update itself if a intvalue changes

hello im having a problem with making a script that checks for a value from the player leaderstats and if its more then 1 it does its thing,but my problem is that the value is aways the starter value when the player loads even if it changes and it is changed it doesnt show in the script and it prints 0 (the number it thinks the value is) heres the script

local plr = game.Players.LocalPlayer
local pack = plr.leaderstats.Potatopack1.Value

local repstorage = game:GetService("ReplicatedStorage")
script.Parent.MouseButton1Click:Connect(function()
	if pack >= 1 then
		pack = pack-1

		script.Parent.Parent.Visible = false
		repstorage.potatopack11:FireServer(plr)
	else print(pack)
		
		
	end
		
end)

If you need to detect if an IntValue changes, you can simply use GetPropertyChangedSignal.

how do i use GetPropertyChangedSignal

pack.Changed:Connect(function()
   --your code on IntValue's value changed
end)

no need to use GetPropertyChangedSignal use .Changed instead

changed doesnt work on .parent or parent related also i figured it out! thanks for the help

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.