Make TextLabel visible when Boolvalue is true

Hello,

I currently have 2 scripts where i am trying to make a textlabel inside a part visible when the boolvalue is true.

the first script is a Localscript, because it is inside a GUI where when you click a button, the button goes to the next page, and the Boolvalue gets True. this script works btw.

The second script what i am trying is when the boolvalue is true, the textlabel inside a part will be visible, but it doesnt work and i dont know how to fix it.
This is my current script of the second script, this is not a localscript because i want other people to see it, and its not working

local boolValue = script.Parent.FromKAM
local part1 = script.Parent.Dir.GUI.TFrKa 

while wait(1) do
	if boolValue.Value == true then
		part1.TextTransparency = 0
	end
end

any errors? Is this a local script or server script? We need more details please

The script in the GUI to make the BoolValue true is a Localscript

The script int he part to make the text visible when the boolvalue is true is a script
There are no errors

where is this script located? That’d help

Also can I see the code for this script?

I’m so confused, like can you show us the heirachy of the GUI in explorer please?

1 Like

thats the script i sent

local boolValue = script.Parent.FromKAM
local part1 = script.Parent.Dir.GUI.TFrKa

while wait(1) do
if boolValue.Value == true then
part1.TextTransparency = 0
end
end

Not that script, the other one

In Roblox, client scripts (like LocalScripts) execute on each player’s device, whereas server scripts run exclusively on the game server. They function within separate environments due to Roblox’s client-server model, which restricts direct interaction between them for security and performance reasons.

Your first script, the LocalScript, effectively updates boolValue to true when a GUI button is clicked. However, the issue arises because changes made on the client-side (where the button is clicked) are not automatically synchronized with the server-side environment.

To address this, you should employ Remote Events. These allow you to communicate information from the client to the server and vice versa. RemoteEvent | Documentation - Roblox Creator Hub.

If you change a value in local script, a server script can’t see

so it’s a server script, is the GUI like a surface GUI in workspace?

local boolValue = script.Parent.FromKAM
local part1 = script.Parent.Dir.GUI.TFrKa 

boolValue:GetPropertyChangedSignal("Value"):Connect(function()
part1.TextTransparency = 0
end)

I’m not sure it will work but it definitely is a more optimized solution, instead of constantly checking when the value changes. You can use an event which will take up less resources.

the GUI where the first script is, is inside a ScreenGUI, inside a Part,
The second script is inside a other part but in same model
The textlabel is not inside the GUI, its inside the other part.

Wouldn’t that not be correct because he wants to check when the Value is true

Yeah I forgot to add that into the code, but you get the idea.

Dude just take a screenshot and show us your saying local and then your saying you want other people too see it your confusing everyone

1 Like

Okay there’s a way to make everyone see this. Using a remote event with fireallclients, add a remote event into replicatedstorage. Then use this code:

-- Do this in a server script in serverscriptservice
local boolValue = -- I'm not sure where the value is located so put that in here
local RE = game.ReplicatedStorage.RemoteEvent -- Add a remote event in replicatedstorage for this to work
boolValue:GetPropertyChangedSignal("Value"):Connect(function()
if boolValue.Value == true then
RE:FireAllClients()
end)
-- Do this in a local script
local RE = game.ReplicatedStorage.RemoteEvent 
local plr = game.Players.LocalPlayer

RE.OnClientEvent:Connect(function()
local part1 = plr.PlayerGui:WaitForChild("ScreenGui") -- I don't know where your part1 thing is either because you haven't sent a screenshot of where your stuff is located so please do
part1.TextTransparency = 0
end)

Now everyone will have this happen on their screen.

Also it’d be nice to have the “Script” is in serverscriptservice by the way

I have a Group, which has 2 parts.
The first Part has a ScreenGUI with a TextButton where the LocalScript is Located.
the Other Part has a SurfaceGUI with a Textlabel with it. Where the serverScript is located

this is the LocalScript That manages the TextButton, to when its clicked it wil make the BoolValue True.

In the Other part, where the SurfaceGUI and Textlabel is located, when the Localscript makes the BoolValue True, then in the SurfaceGUI, a TextLabel Will be Visible
This is my Script inside the SurfaceGUI.

This is my Workspace of the other Part.

image

As I said before, you need to read up on RemoteEvent | Documentation - Roblox Creator Hub. You probably want something like:

LocalScript on the Button (Client Side):

local button = script.Parent  -- Assuming the script is inside the button

button.MouseButton1Click:Connect(function()
    -- Notify the server about this change using a RemoteEvent
    game.ReplicatedStorage.ChangeBoolValue:FireServer(true)  -- FireServer with the new value
end)

Server Script (Server Side):

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local changeBoolValueEvent = ReplicatedStorage:WaitForChild("ChangeBoolValue")

local boolValue = script.Parent.FromKAM
local part1 = script.Parent.Dir.GUI.TFrKa

-- Function to toggle visibility based on boolValue
local function toggleVisibility()
    if boolValue.Value == true then
        part1.TextTransparency = 0
    else
        part1.TextTransparency = 1
    end
end

-- Initial setup
toggleVisibility()

-- Connect to GetPropertyChangedSignal to monitor changes after initial setup
boolValue:GetPropertyChangedSignal("Value"):Connect(function()
    toggleVisibility()  -- Call toggleVisibility whenever boolValue.Value changes
end)

-- Function to handle the RemoteEvent fired from the client
changeBoolValueEvent.OnServerEvent:Connect(function(player, newValue)
    -- Update the boolValue
    boolValue.Value = newValue
end)

1 Like

this script worked thank you so much
and sorry for not understanding everyone my english is not perfect

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.