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

[Solved]Why wont this piece of code add to the string value?

GUI.Button1.MouseButton1Click:connect(function()
	a = z + 1
	script.statusv1.Changed:connect(function()
	statusv1.Value = a
		end)
	end)

I'm trying to change a string value with a variable but the value is not changing.

statusv1 is the string value.

1 answer

✓ Accepted answer

First off, the Changed event is only fired when the targeted instance is changed. There is no need to make an event to wait for that if you only mean to set it. Second off, you need to know what a StringValue is. A StringValue holds a string, like "Hello!". What you seem to be looking for is an IntValue, which holds integers. If you are looking at saving real numbers try out NumberValues for size.

In other words, to fix your problem:

  1. Change script.statusv1 to an IntValue
  2. Replace the code block you have provided us with with the one bellow:
GUI.Button1.MouseButton1Click:connect(function()
	local a = z + 1 -- Making a local keeps it within the scope. I am also assuming that you already have z defined
	script.statusv1.Value = a

1 comment

0

thanks for the help

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