Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[HELP! Why wont the Status Bar go visible? Recognizes boolean change.

Hello everyone, i am having trouble with my boolean value for my Menu in my game, the main problem i'm having is that the script doesnt recognize the boolean value changing, or if it does than it doesnt update.

For my layout, i have a boolean value under a ScreenGUI in starter gui, under that screen gui is a Localscript.

Under Starter gui i have another ScreenGUI, with a frame (Its supposed to be a game status bar, but this isnt important), under that screen GUI is a local script.

Anyways, here is my code for the first script (Which is the first one in Starter GUI


--This recognizes the boolean value and sets it to false, when it is false, the frame in the second --Screen Gui wont show up, which is exactly what i want.
local MenuOver = script.Parent:FindFirstChild("MenuOver")
MenuOver.Value = false
print(MenuOver.Value) --This successfully prints

If you are wondering what the main code looks like, here it is, it isnt important but if you think it has something to do with the problem then here it is.

PLEASE IGNORE THIS CODE

local GamePopup = script.Parent:WaitForChild("GamePopup")
local Background = GamePopup:WaitForChild("Background")
local Teleporting = GamePopup:WaitForChild("Teleporting")
local Wait = GamePopup:WaitForChild("Wait")
local Lib = GamePopup:WaitForChild("Lib")
--Camera
local Cam = game.Workspace.CurrentCamera
local CamPoints = workspace:WaitForChild("CameraPoints")



--Tweens
local SlideInSidebar = Tween:Create(Sidebar,TweenInfo.new(0.69, Enum.EasingStyle.Quad, Enum.EasingDirection.Out,0, false, 0),{Position = UDim2.new(0,0,0,0)})
local SlideOutSidebar = Tween:Create(Sidebar,TweenInfo.new(0.69, Enum.EasingStyle.Quad, Enum.EasingDirection.Out,0, false, 0),{Position = UDim2.new(-1,0,0,0)})



-- CLOSE BACKGROUND GUI
local images = {"http://www.roblox.com/asset/?id=4756555748", "http://www.roblox.com/asset/?id=4756556665", "http://www.roblox.com/asset/?id=4756563878","http://www.roblox.com/asset/?id=4756798215", "http://www.roblox.com/asset/?id=4756802332", "http://www.roblox.com/asset/?id=4756824289", "http://www.roblox.com/asset/?id=4756825065", "http://www.roblox.com/asset/?id=4756826088"}

wait(5)
print(images)
script.Parent.GamePopup.Background.Image = images[math.random(1, #images)]
wait(5)
print(images)
script.Parent.GamePopup.Background.Image = images[math.random(1, #images)]
wait(5)
print(images)
script.Parent.GamePopup.Background.Image = images[math.random(1, #images)]

--Hides Gamepopup
script.Parent.GamePopup.Background.Visible = false
script.Parent.GamePopup.Visible = false
script.Parent.GamePopup.Teleporting.Visible = false
script.Parent.GamePopup.Wait.Visible = false
script.Parent.GamePopup.Lib.Visible = false
--Changes the camera
Cam.CameraType = Enum.CameraType.Scriptable
Cam.FieldOfView = 90

--Plays the cutscene
SlideInSidebar:Play()
local function TweenCameraPos(Point, Speed)
	Tween:Create(Cam, TweenInfo.new(Speed, Enum.EasingStyle.Linear),{CFrame = Point.CFrame}):Play()
end

-- Plays Animation
	Cam.CFrame = CamPoints:FindFirstChild("1").CFrame
    TweenCameraPos(CamPoints:FindFirstChild("2"),4)
	wait(4)
	Cam.CFrame = CamPoints:FindFirstChild("3").CFrame
    TweenCameraPos(CamPoints:FindFirstChild("4"),4)
	wait(4)
	Cam.CFrame = CamPoints:FindFirstChild("5").CFrame
    TweenCameraPos(CamPoints:FindFirstChild("6"),4)
	wait(4)
	Cam.CFrame = CamPoints:FindFirstChild("7").CFrame
    TweenCameraPos(CamPoints:FindFirstChild("8"),4)
	wait(4)
	Cam.FieldOfView = 60
	game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
	game.Workspace.CurrentCamera.CameraType = "Custom"
	SlideOutSidebar:Play()

****IMPORTANT PART HERE

--This is the part where the Menu is over, so now the other local script,  recongnizes that the -------Menu is over from the boolean value and it should update, right?
MenuOver = true
print(MenuOver) -- This successfully prints

Now here is the code for the second script

local MenuOver = script.Parent.Parent.Menu:FindFirstChild("MenuOver")
local StatusText = script.Parent.TopBar.Status.Text
local IntermissionTime = 20
local StatusBar = script.Parent.TopBar
wait()
--Makes the Status Bar invisible in the beginning of the game
StatusBar.Visible = false
print(MenuOver.Value)

--Detects if the menu is over, if it is, then make the GUI visible.
if MenuOver.Value == true then 



print("Detected Menu was over")
wait()
script.Parent.TopBar.Visible = true
StatusText = "Intermission,"..IntermissionTime.." seconds left!"

end

I am not getting any errors, and the game prints correctly, the only problem is that the TopBar doesnt go visible like it is supposed to.

I am really desperate and have tried for about 2 hours now, can someone tell me what is wrong?

1 answer

✓ Accepted answer

The most likely problem is with the last script. You're quickly checking if it's true, and not handling what happens if it changes after you've checked. You should listen for the PropertyChanged signal:

local MenuOver = script.Parent.Parent.Menu:FindFirstChild("MenuOver")
local StatusText = script.Parent.TopBar.Status.Text
local IntermissionTime = 20
local StatusBar = script.Parent.TopBar
wait()
--Makes the Status Bar invisible in the beginning of the game
StatusBar.Visible = false
print(MenuOver.Value)

--Detects if the menu is over, if it is, then make the GUI visible.
MenuOver:GetPropertyChangedSignal("Value"):Connect(function() -- As soon as (and every time) that Value changes, run the below code
	if MenuOver.Value == true then 
		print("Detected Menu was over")
		wait()
		script.Parent.TopBar.Visible = true
		StatusText = "Intermission,"..IntermissionTime.." seconds left!"
	end
end)

You're also setting it to false, then to true instantly after. Just change one or the other. Learn more about GetPropertyChangedSignal here.

3 comments

0

Thank you! And I wanted to know one thing, instead of asking a whole new question, I thought'd i would ask you since you seem to have lots of scripting knowledge :) I wanted to know how to make the main menu script run only ONCE. Because right now it runs everytime the player dies, how do i do this?

0

How you would do this is disable ResetOnSpawn. ScreenGUIs have a property called "ResetOnSpawn", and it basically "refreshes" all the GUIs and the scripts inside them. Disable that on the ScreenGUI holding your LocalScript.

0

You could also place the script in StarterPlayer - StarterPlayerScripts. They don't run everytime you spawn that way.

This discussion is preserved as it was. New answers, comments, and votes are closed.