Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by 4 years ago

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?

0
Loop it. PrismaticFruits 842 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
MenuOver:GetPropertyChangedSignal("Value"):Connect(function(newValue) is a better format Ziffixture 6913 — 4y
1
Well you learn something everyday. Thanks man. radiant_Light203 1166 — 4y
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) SimplyBloo 27 — 4y
0
Try changing MenuOver to MenuOver.Value. radiant_Light203 1166 — 4y
View all comments (2 more)
0
try to do what Feahren did. I dont think a property can have an event at the same time. 123nabilben123 499 — 4y
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. radiant_Light203 1166 — 4y
Ad

Answer this question