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

How do you make line 3 to 9 update the string of the GUI text without resetting?

Asked by 8 years ago
local isOn = game.Workspace.DOM.isAvailable -- Location of the bool value

if isOn.Value == false then
    script.Parent.Text = "DOM Check-in(Closed)" -- How do you make this part update the string of the gui text without resetting?
    print("Is not on")
else
    script.Parent.Text = "DOM Check-in(Opened)"
    print("Is on")
end

function on() -- These are just here to let you understand what is going on. Or you can edit them..
    isOn.Value = true
    game.Workspace.DOM.isAvailable.Value = true
    script.Parent.Text = "DOM Check-in(Opened)"
end 

function off()
    isOn.Value = false
    game.Workspace.DOM.isAvailable.Value = false
    script.Parent.Text = "DOM Check-in(Closed)"
end

function Click()    
    if isOn.Value == true then off() else on() end
end

script.Parent.MouseButton1Down:connect(Click)

I have tried while wait(0.5) do but it wont let me toggle the bool value using the button text GUI. Plez halp meh ;-;

0
This will remain as an unanswered question ;-; supermarioworld323 45 — 8y

1 answer

Log in to vote
0
Answered by
pyro89 50
8 years ago

For one thing, you can add Local values to change and have them set to when certain things happen. Thus, if so-and-so happens in-game and the script detects it happening, then one of the preset Texts will change, and the Preset Text will change. Since they look for the local value PresetText instead of creating an entirely new set of text that you have to write yourself, it can be changed at ease and the buttons will follow it when the button detects being clicked.

local isOn = game.Workspace.DOM.isAvailable -- Location of the bool value
local PresetTextClosed = "DOM Check-in(Closed)"
local PresetTextOpened = "DOM Check-in(Opened)"

if isOn.Value == false then
    script.Parent.Text = PresetTextClosed -- How do you make this part update the string of the gui text without resetting?
    print("Is not on")
else
    script.Parent.Text = PresetTextOpened
    print("Is on")
end

function on() -- These are just here to let you understand what is going on. Or you can edit them..
    isOn.Value = true
    game.Workspace.DOM.isAvailable.Value = true
    script.Parent.Text = PresetTextOpened
end

function off()
    isOn.Value = false
    game.Workspace.DOM.isAvailable.Value = false
    script.Parent.Text = PresetTextClosed
end

function Click()   
    if isOn.Value == true then off() else on() end
end
script.Parent.MouseButton1Down:connect(Click)
0
thank you c: supermarioworld323 45 — 8y
Ad

Answer this question