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

How can a script know if something happened?

Asked by 8 years ago

Like how can I make a script know when a timer reaches 0 or how would I know when all the fire in this brick is gone? I'm just wondering what I would use or how I would go about this. I'm not interesting in anyone coding these examples. Thanks.

2
I'd suggest using the .Changed and ChildRemoved event to detect when something has changed/or been removed http://wiki.roblox.com/index.php?title=API:Class/Instance/Changed http://wiki.roblox.com/index.php?title=API:Class/Instance/ChildRemoved DevSean 270 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Along with the links given in the above comment to your question; usage of Changed could be useful.

Changed will fire every single time a property of an Instance is changed. Lets say we already have an IntValue inside of Workspace. Now, That IntValue is already counting down due to some other script, we want to use the Changed event of IntValue.

game.Workspace.IntValue.Changed:connect(function(Property)
    if game.Workspace.IntValue.Value == 0 then
        print("The Time Has Struck 0!")
    end
end)

The above script makes use of Changed to check the IntValue every time a Property changes, allowing us to use a conditional to see if the Value is 0, if so, we print something. In the parenthesis near function, you see Property which is a 'variable' that will give a string of the Changed property.

Note Changed fires for ANY property change! Even name changes!

Ad

Answer this question