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

Gui dosen't update correctly?

So, I need some help to figure out why this gui isn't Updating when i uncheck/check the Value i need it to be so if the isJobActive value if checked then the gui is visible but if the value isnt checked then the gui gonna be invisible.

Here's The Current Script:

local isJobActive = script.Parent.isJobActive

while true do	
	if isJobActive.Value == false then
		script.Parent.EndJob.Visible = false
	end
	if isJobActive.Value == true then
		script.Parent.EndJob.Visible = true
	end	
end	

1 answer

You do not need to use a loop to change the gui visibility.

You can use the Changed event.

It is also possible to remove all of the if statements by inverting the value when changed.

e.g.:-

local EndJob =  script.Parent.EndJob  --make a variable of the endjob 

script.Parent.isJobActive.Changed:connect(function (newValue) -- the changed event passes the new value as its argument
EndJob .Visible = not newValue -- inverts the current value and passes it to endjob

-- e.g. true becomes false, endjob is set to false
end)

Hope this helps, pls comment If you do not understand how / why this code works.

3 comments

0

It dosen't work, When i uncheck the Value then nothing happenes

0

Is it a local script or a server script. Also can you confirm that this script is being ran by adding prints in.

0

it is a server script

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