Textlabel not visible when bool value changes

Hi i am trying to make a textlabel visible when 1 of the 2 bool values changes both values are intvalues that do change as you can see it change in game and in rep storage. thank you in advace

text = script.Parent

local blueteam = game.ReplicatedStorage.guiteamboolean.blueteam.Value

local greenteam = game.ReplicatedStorage.guiteamboolean.greenteam.Value

while true do

wait(.2)

if blueteam == greenteam then

text.Visible = false

end

if blueteam > greenteam then

text.Parent.Visible = true

end

if blueteam < greenteam then

text.Parent.Visible = false

end

end

Try this

local text = script.Parent
local blueteam = game.ReplicatedStorage.guiteamboolean.blueteam
local greenteam = game.ReplicatedStorage.guiteamboolean.greenteam

local function Load()
	if blueteam.Value == greenteam.Value then
		text.Visible = false
	elseif blueteam.Value >= greenteam.Value then
		text.Parent.Visible = true
	elseif blueteam.Value <= greenteam.Value then
		text.Parent.Visible = false
	end
end

greenteam.Changed:Connect(Load)
blueteam.Changed:Connect(Load)

Hi Mate i gave it a shot in a local and server script there is no error but it still does not make the textlabel appear or disappear. any other thoughts?

I forgot to add Load()

local text = script.Parent
local blueteam = game.ReplicatedStorage.guiteamboolean.blueteam
local greenteam = game.ReplicatedStorage.guiteamboolean.greenteam

local function Load()
	if blueteam.Value == greenteam.Value then
		text.Visible = false
	elseif blueteam.Value >= greenteam.Value then
		text.Parent.Visible = true
	elseif blueteam.Value <= greenteam.Value then
		text.Parent.Visible = false
	end
end

Load()
greenteam.Changed:Connect(Load)
blueteam.Changed:Connect(Load)

it works just fine for me may I see your explorer?

he doesn’t want to detect if both values are changed,

text = script.Parent

local blueteam = game.ReplicatedStorage.guiteamboolean.blueteam

local greenteam = game.ReplicatedStorage.guiteamboolean.greenteam

blueteam.Changed:Connect(function()

if blueteam == greenteam then

text.Visible = false

elseif blueteam > greenteam then

text.Parent.Visible = true


if blueteam < greenteam then

text.Parent.Visible = false

end

greenteam.Changed:Connect(function()

if blueteam == greenteam then

text.Visible = false

elseif blueteam > greenteam then

text.Parent.Visible = true


if blueteam < greenteam then

text.Parent.Visible = false

end

that’s the same as my code but without using a function

no your code will only work if both values are changing for ex :
lets say Value1 changed
the Load function is not going to work.
both values have to change

it will work

if the greenteam value or the blueteam value changes then it will call the load function

see

greenteam.Changed:Connect(Load)
blueteam.Changed:Connect(Load)

both are connected to the function load which means the function will run only if greenteam value AND blueteam value changes

it will work the greenteam value or the blueteam value changes I tested it and it worked just fine

Functions

i tried it out but still seem to not work for me
do you have a place i can view ?

I think part of your problem is your declaring the team variables to the values at top and never updating in your while loop use .Value in the while loop to check current values. Also the text.Visible may need to be text.Parent.Visible

try the below code with use of .Value as current not set to value at top

local text = script.Parent

local blueteam = game.ReplicatedStorage.guiteamboolean.blueteam  -- don't use value here it only sets once if you do that
local greenteam = game.ReplicatedStorage.guiteamboolean.greenteam -- don't use value here it only sets once if you do that

while wait(.2) do
	if blueteam.Value == greenteam.Value or blueteam.Value < greenteam.Value  then  -- use .Value to check the current value
		text.Parent.Visible = false   -- did you mean to use text.Parent.Visible here instead of the text.Visible
	elseif blueteam.Value > greenteam.Value then  -- do elseif the top 2 not true
		text.Parent.Visible = true
	end
end
1 Like