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

Why wont the Gui update with the boolean value? No erros.

Having a problem with my code, trying to script a gui to show up when the value = true. I have two scripts, one is a local script under a screen GUI in starter gui, and the second script is a local script, here is an image of everything:

https://imgur.com/a/ariuqWZ

local MenuOver = script.Parent:FindFirstChild("MenuOver")
MenuOver.Value = false
print(MenuOver.Value)

First of all, the value of menu over prints properly like its supposed to.

After this part is some other code for the menu, but that isnt important.

Here is the second part of the script

MenuOver.Value = true
print(MenuOver.Value)
SlideOutSidebar:Play()

It also prints properly here as well.

Now here is the second script:


local Tween = game:GetService("TweenService")
local MenuOver = script.Parent:FindFirstChild("MenuOver")
local StatusText = script.Parent.Status.TopBar.Status
local StatusBar = script.Parent.Status.TopBar

print(MenuOver.Value) -- This prints successfully

local SlideInSidebar = Tween:Create(StatusBar,TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out,0, false, 0),{Position = UDim2.new(0.2,0,0,0)})


if MenuOver.Value == true then
SlideInSidebar:Play()
print(MenuOver.Value)
end
StatusText.Text = workspace.Game.GameRun.Status.Value

Not sure why, but it doesnt do anything inside of the if true then part, why is that?

1 comment

0

Loop it.

1 answer

Is it inside of a function or is it just plain outside? If it's not in a function then the problem is that it runs once and if MenuOver is not true it won't do anything. I recommend that you use a MenuOver.Changed:Connect() and nest the if condition inside of it.

Something like:

MenuOver.Changed:Connect(function()
	-- put your if condition here.
end)

6 comments

0

MenuOver:GetPropertyChangedSignal("Value"):Connect(function(newValue) is a better format

1

Well you learn something everyday. Thanks man.

0

Thanks for your answer! But i am now getting this error: - Players.SimplyBloo.PlayerGui.LocalStatus:7: attempt to index local 'MenuOver' (a nil value)

0

Try changing MenuOver to MenuOver.Value.

0

try to do what Feahren did. I dont think a property can have an event at the same time.

0

I don't see why MenuOver, a bool value, would return a nil value unless MenuOver isn't a direct child of the script's parent.

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