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

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

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 ;-;

1 comment

0

This will remain as an unanswered question ;-;

1 answer

✓ Accepted answer

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)

1 comment

0

thank you c:

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