Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How could I get my script to update a value whenever it changes?

I have a button and it should only do something when a value in your player is a specific value. Here is the part of the script:

p.ClickDetector.MouseClick:Connect(function(plr)
	if plr.Character.Torso.Person.Transparency == 0 and plr.Role.Value == "I" then

Basically it checks if the character has the specific StarterCharacter and if their role is "I". I know there's nothing wrong with the script because I have tested it without the Role thing. Theres a stringvalue inside the player and it is blank when the player joins, but I edited it when I clicked it and it acted like the value was blank. But when it is added to the player with the value "I", it works. I'm not sure how to word this, so... How can I fix this?

1 answer

You could use the .Changed event. The .Changed event checks if a value's value changes, and then runs the code inside like so:

value.Changed:Connect(function()
	--Code goes here!
end)

4 comments

0

i dont understand

0

No it doesn't, it checks if a n y property changes.

1

Instance:GetPropertyChangedSignal("Value"):Connect(Callback)

0

Well, yeah, it would work fine though as long as he is not deciding to go crazy with parenting or changes the name too much. This worked fine for me.

This discussion is preserved as it was. New answers, comments, and votes are closed.