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

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

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.

1 comment

0

Use the Changed event on CF.TextBubble

1 answer

✓ Accepted answer

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

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