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

Is it possible to detect if a StringValue's Value changed and loop? Click for more details!

Asked by 7 years ago

I'm trying to use this script;

    local String1 = CF.TextBubble.WhatToSay
    local Length1 = string.len(String1.Value)

    for i = 1,Length1 do
        wait()
        CF.TextBubble.Text = string.sub(String1.Value,1,i)

BUT this will only function once. I want to detect if the WhatToSay Value has changed if it has then loop if it hasn't then returned.

This is what I can think of

while String1.Changed do
--Code

But I'm not sure if it will work.

Any help is apperciated.

0
Use the Changed event on CF.TextBubble Azarth 3141 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

Hey BlackOrange3343,

I would use the .Changed event of the WhatToSay Value. Then, I would put all of the code in there that I need it to do when the value is changed. Below is a personal example.

local value = script.Parent -- Declares a variable for the value.

value.Changed:Connect(function(val) -- Anonymous function using the .Changed event of the value. Notice that you do .Changed to the Object value not the Value that it holds. If I wanted to do it to the value it holds I would've done value.Value but, that doesn't have a .Changed event.
    print("The value has changed...") -- Prints "The value has changed..."
end) -- end for the anonymous function, make sure that parenthesis is there at the end 'cause that's how anonymous functions work. 

Well, I hope I helped in one way or another and the links will be below for the difficult methods I used.

.Changed Event of a Value

Anonymous Functions

~~ KingLoneCat

Ad

Answer this question