Detecting Value Changed?

Hey there so I’ve got a IntValue Inside of a part and I’m trying to make it Print something whenever the value is changed but It doesn’t work and also doesn’t give me an error Any help or suggestions are much appreciated.

script.Parent.Changed:Connect(function(plr)
	print("B")
end)
1 Like

How are you changing the value?

Edit: Are you changing the value from the client or server? Also, is the script local or server sided?

2 Likes

It’s a normal script so Server Sided.

1 Like

Are you changing the value from the server or client?

1 Like

If the script is parented to the part then you need to do it like this:

script.Parent.IntValue.Changed:Connect(function(plr)
	print("B")
end)
--IntValue  or whatever you named it
1 Like

Yeah I don’t know but when I first started using valueobjects they were like this and glitched a lot without really a good explanation. Try putting the script in ServerScriptService? I think a script that’s parent to it wont work.

1 Like

If you’re testing in Studio and using the Play Solo mode (where you’re controlling your character), then you need to switch to the Server mode before you change the value, because it’s a server-side script listening for the change. From the Client mode, the change isn’t picked up by the server:

client << Client (won’t see change) | Server (will see change) >> server

I was trying to debug a similar issue for like 30 minutes the other day, and this was the problem.


Side-note, but the argument passed to Changed for BaseValue objects is the new value. So the argument plr will be the new value. Might want to use a better name, because it looks like “player” but isn’t the player.

4 Likes

script.Parent:GetPropertyChangedSignal(“Value”):Connect(function()
print(“changed”)
end)
getpropertychangedsignal is better for only checking if a single property is changed

1 Like

Thank you for all the replys! Turns out like Crazyman32 said I was changing it from the Client side and not the server side. Thanks again everyone.

1 Like