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

How can I use a Changed event to continuously check for a changed IntValue?

I want to have an IntValue displayed on a surface gui. So I wrote something like this:

value = game.Workspace.IntValue
text = script.Parent --inside textlabel

value.Changed:connect(function()
	text.Text = tostring(value)
end)

I don't know what I need or what I did wrong but it doesn't recognize any change in value and/or won't change the displayed value. That's why I am reaching out for any sort of tip.

2 answers

try using this method. Since a int value only has 2 values (their name and int number) you can use :Connect(function(c) when "c" is the change so you would want

value = game.Workspace.IntValue
text = script.Parent --inside textlabel

value.Changed:connect(function(c)
    text.Text = tostring(c)
end)

try this and tell me if it works!

2 comments

0

So I edited the code to have the parameter, event adding a print to display the value first. Basically looks exactly like what you put, and nothing happens. If it makes a difference, I am changing the value of the IntValue directly in it's property menu. I was curious if this might be a client-server issue needing remote functions/events?

0

make sure it is a server script

u diddnt use Connect because connect is deprecated

	value = game.Workspace.IntValue
	text = script.Parent --inside textlabel
	 
	value.Changed:Connect(function()
	    add.Value to tostring(value)-- what u gonna see
	end)

1 comment

0

anyway i go sleep so i probs cant reply if u ask a question lol

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