Hello there, I have a LocalScript here where the TextButton and TextLabel's visiblity is supposed to be set to false once the BoolValue is set to false, however it does not seem to work, no output errors or whatsoever, how do I remedy this?
local plr = game:GetService("Players").LocalPlayer local value = plr.PlayerScripts.Value local button = script.Parent button.MouseButton1Click:Connect(function() value.Value = false end) local function trigger() button.Visible = false plr.PlayerGui.Roll.TextLabel.Visible = false end if value == false then trigger() end
This is because you're not actually listening for the value that's getting changed. Depending on what you're trying to do there may be a better way to go about this. In this case though you could do something like this:
local Players = game:GetService("Players") local player = Players.LocalPlayer -- For values like these I like to put them in the character, but -- I guess the location doesn't matter too much local value = player.PlayerScripts:WaitForChild("Value") local button = script.Parent button.MouseButton1Click:Connect(function() value.Value = false end) local function trigger() button.Visible = false plr.PlayerGui.Roll.TextLabel.Visible = false end -- Here is where you want to setup the connection which -- will listen for the value being changed value.Changed:Connect(function(newValue) if newValue == false then trigger() end end)
You can read more on the Changed event here.