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

How do you make a text changer with a SurfaceGUI?

Asked by 5 years ago

I have an opening/closing system for a bank. I have a BoolValue inside Workspace. The value is called opened. This value determines if the bank is opened or closed. If the value is true, than the bank is open. If the value is false, the bank is closed. I also have a Part in the workspace with a SurfaceGui. Inside that, there is a TextLabel. I have a Script inside the TextLabel. I used the :GetPropertyChangedSignal() function, but it didn't work.

I think I messed up with the script, but I don't know.

Here's the script:

local text = script.Parent.Text
local open = script.Parent.Parent.Parent.Parent.Opened

open:GetPropertyChangedSignal("Value"):Connect(function()
    if open.Value == true then
        text = "Opened"
    else
        text = "Closed"
    end
end)

Any help??

0
You need to use a LocalScript to make changes on Guis, but dont put the LocalScript in the Workspace, place it in a Client-Specific Area, like StarterGui, you'll have to manually input the "text" and "opened" variables SerpentineKing 3885 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

# Values and References

The problem here if that your text variable is a value, not a reference.

The problem with using a value and not a reference, is that the value isn't attached to the object itself. Thus, if you change anything in the object, the value doesn't update.

Application


With that said, you can do the following:

```lua local t = script.Parent local open = script.Parent.Parent.Parent.Parent.Opened

open.Changed:Connect(function() if open.Value then t.Text = "Opened" else t.Text = "Closed" end end) ```

Keep in mind here as objects such as the boolvalue only have one property of importance, it is ok to use the Changed event instead of GetPropertyChangedSignal(). For all other types of objects, you should use the GetPropertyChangedSignal function

Hopefully this helped, be sure to accept if it did!

0
open.Value == true .............. User#5423 17 — 5y
Ad

Answer this question