Script with ValueObject not working as intended

Hello!
I am Trying to Use :GetPropertyChangedSignal(“Value”) To get When The Value Changes.
However, My script Is not Detecting the Change.

game.ReplicatedStorage.ObbyTime:GetPropertyChangedSignal("Value"):Connect(function()
	print("A Second Passed In Obbby")
		if game.ReplicatedStorage.ObbyTime.Value == 0 then
			print("Obby Over")
   end
end)

When i test It Out, I see No Prints in the output. The value is In replicated Storage and Is Changing every Second. I am Using This script in ServerScriptService as a Script

Instead of using GetPropertyChangedSignal function, you can use Changed event on IntValues

game.ReplicatedStorage.ObbyTime.Changed:Connect(function()
    print("A Second Passed In Obbby")

    if game.ReplicatedStorage.ObbyTime.Value == 0 then
        print("Obby Over")
    end
end)

If it still doesn’t work, could I learn what type of script it is?

But If I Use GetPropertyChangedSignal It should work Too Right? What did i do wrong

It is just an alternative. Try using it.

Did not work. I tried it With Changed

Solution → The Issue was Totally My Fault :grinning_face_with_smiling_eyes:
I was Using the Script inside A Remote event and Forgot to Fire It.

1 Like

Try to move ObbyTime value object to workspace:

(Read your solution, but you can try this :>)

workspace.ObbyTime.Changed:Connect(function()
	print("A Second Passed In Obby")
	if workspace.ObbyTime.Value <= 0 then
		print("Obby Over")
	end
end)
1 Like

It looks like you’re trying to achieve a countdown script. Try something around RunService and os.clock() like this. An alternative substitute with os.clock() might be time().

local RunService = game:GetService("RunService")

local function startCountdown(duration)
	local start = os.clock()
	while os.clock() - start < duration do
		RunService.Heartbeat:Wait()
	end
    -- any other line here
	print("Countdown expired.")	
end
1 Like