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
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.
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.
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.
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)