Changing StringValue 3 times in a heartbeat triggers .Changed event 3 times

If you run this script

local val = Instance.new("StringValue", script)
local function update()
	print("Changed", val.Value)
end

val.Changed:Connect(update)


val.Value = "Test"
val.Value = ""
val.Value = "Test2"

You’ll get the output:

Changed Test2 (x3)

The correct behaviour should be ONE trigger per heartbeat.

Changed Test2

or atleast

Changed Test
Changed 
Changed Test2

It should not have printed 3 times, and if it did it should not have printed same value every time.

3 Likes

What is the value of Workspace.SignalBehavior?

2 Likes

Like @EmeraldSlash said, check the value of Workspace.SignalBehavior in explorer. If it’s deferred (which seems to be the default value in my experience), try changing it to anything else besides that, and it should print this:

Changed Test
Changed 
Changed Test2
2 Likes

Thanks guys! Seems like changing it to Default fixed the issue.

Keep in mind this won’t exist forever. Eventually, the default will likely become Deferred and long after that, Immediate will be removed entirely, I wouldn’t recommend architecting your code to rely on the behaviour.

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