How to detect value changes?

How do i make it so that a script will wait until a value will change into something specific?
please ask an questions u have

1 Like

Use the Changed Event for Value Objects:

local Value = workspace.BoolValue

Value.Changed:Connect(function(NewValue)
    --Do stuff here
end)
5 Likes

well, can you explain more? what kind of value? what do you want to change it to?

1 Like

so basically i want to make a script that will check if a string value changed to “RocketLauncher”
and if it gets detected as “RocketLauncher” then itll execute a code

–sry its kinda hard to explain lol

StringValue.Changed is what you need possibly

You’re able to store a string inside here, and detect if the current String is equal to “RocketLauncher” or not using the Changed event

Would i change "the “BoolValue” to what ever or is there a step i need to take?
– could i change the path to “workspace.Weapon.Value”

1 Like

Pretty much, as long as you’re able to access the Value anywhere inside the script then you should be fine