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

Why is the GUI not turning visible when a value has been changed?

Asked by 2 years ago
Edited 2 years ago

Hello everyone! I have a script which changes a player value's value (a player value) and a local script which detects when the value has been changed. If it was, it will make a UI visible.

local player = game.Players.LocalPlayer
local CODR = player:WaitForChild("CODR") -- a boolean value
CODR.Changed:Connect(function(val)
    script.Parent.Visible = true
end)

But the UI was not turning visible. I decided to add a print statement in front of the line telling the UI to turn it visible saying "script.Parent.Visible". the Output printed 'true'

local player = game.Players.LocalPlayer
local CODR = player:WaitForChild("CODR") -- a boolean value
CODR.Changed:Connect(function(val)
    script.Parent.Visible = true
    print(script.Parent.Visible) -- output printing true
end)

Output = true but the UI is not turning visible By the way, the script thats changing the value is located in a model in the workspace

0
is the screen gui enabled? ISkyLordDoge 37 — 2y
0
Yes ghostbettert 30 — 2y
0
When I make it visible on the studio, it works ghostbettert 30 — 2y
0
send pics of workspace while ur in game sne_123456 439 — 2y

2 answers

Log in to vote
0
Answered by 2 years ago

Hello there.

If its a Boolean value, there's really no need to use

CODR.Changed

Instead, you could use a while loop

while true do
    wait(0.00001)
    if CODR.Value == true -- or false then
        script.Parent.Visible == true
    end
end)

I hope this answers your question

  • RetroBuild / IBulid3

P.S. if you change the value to false then do this in the script

while true do
    wait(0.00001)
    if CODR.Value == false -- or true then
        script.Parent.Visible == false
    end
end)
0
I need the local script to run when a part has been touched (which is why I used the script) ghostbettert 30 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Hello everyone, I have solved the problem myself! Apparently I had to make the UI visible on the script instead of in the local script but I have no clue why

Answer this question