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

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

Asked by 9 years ago
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

Log in to vote
1
Answered by 9 years ago

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
0
thanks for the help rabidhalofan12345 55 — 9y
Ad

Answer this question