Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

event Changed(Property property) - How To

Asked by 10 years ago

Hi guys; I have a script that I want to be fired when a numbervalue changes from 0 to 1 however I cannot find any good tuts on how to use the Changed event. The value is kept in an another group called values from the script.

Script > Values > Value 1 (This has the number value)

Thanks for your time guys. Goldenggamper

Edit --- I'm hoping that one of you guys might be able to lead me into the right direction on how to use the Changed event. How do you tell it what value it should be looking at for it to trigger the event, etc.

0
I'm not sure what you're asking. Could you clarify? User#11893 186 — 10y

3 answers

Log in to vote
1
Answered by 10 years ago

To use the change event, you should use it on a part/value, I will use an IntValue as an example:

game.Workspace.IntValue.Changed:connect(function()
    -- do stuff
end)

The above function will run every time a property of the object has been modified. Hope I helped.

Ad
Log in to vote
1
Answered by
User#2 0
10 years ago

Ah, so you want to learn about the Changed event.

What it does is fire every time any of an object's properties changes, and supplies an Property argument, which is a string name of the property that changed (such as "BrickColor" or "Transparency").

To make it watch a specific property, just add an if statement for the property.

SomeObject.Changed:connect(function(Property)
    if Property == "Transparency" then
        print("Transparency changed!")
    end
end)

That would pring Transparency changed! every time SomeObject's Transparency property changed.

0
Is there a way to check the value of said property as well? Such as if I want the script to do one thing when Property is "Transparency" and true, but something else when Property is "Transparency" and false? deaththerapy 60 — 10y
Log in to vote
-1
Answered by 10 years ago

Thanks to 18cwatford and Owenrules12 for their previous help :)

Answer this question