Number Value GUI's

I am wondering how would I make a GUI appear when a numbervalue.Value == 12?
This is a single player game if that changes anything

Can you elaborate more on what you want to be done?

You can listen to value changes using GetPropertyChangedSignal() assuming numbervalue is a NumberValue object.

numbervalue:GetPropertyChangedSignal("Value"):Connect(function()
       if numbervalue.Value == 12 then
               --make gui visible
       end
end)

I am working on a game based on an alien planet, I need a GUI and a block to appear when you fully repair your ship. This is for the ending. Is there any way to do this, or make a different way to end the game?

hmmm, okay so If i put this script in the NumberValue would it be:

local numbervalue = script.parent
numbervalue:GetPropertyChangedSignal(“Value”):Connect(function()
if numbervalue.Value == 12 then
game.StarterGui.Ending.Frame.Visible = true
end
end)
???

Im kinda new at this

looks good, for future reference when posting code you can wrap it in a code block to make it more readable using ``` at the start and end.

ok ill try this, would it be a local script or no?

Yes, it should be a localscript if you want it to work.

Ok ill try this and let you guys know!!

Should be a local script also just noticed something, you can’t access UI elements directly from StarterGui either use the local player to go through PlayerGui or directly from the script. (if you can send a screenshot of the Gui hierarchy i can provide further help if you need it)

wait so it would be
‘’'local numbervalue = script.parent
numbervalue:GetPropertyChangedSignal(“Value”):Connect(function()
if numbervalue.Value == 12 then
game.localplayer.PlayerGui.Ending.Frame.Visible = true
end
end)
?

LocalPlayer is an attribute of the Players service, that being said it should be game.Players.LocalPlayer:WaitForChild('PlayerGui').Ending.Frame.Visible = true

ok so the completed script would be

‘’‘local numbervalue = script.parent
numbervalue:GetPropertyChangedSignal(“Value”):Connect(function()
if numbervalue.Value == 12 then
game.Players.LocalPlayer:WaitForChild(‘PlayerGui’).Ending.Frame.Visible = true
end
end’‘’
?

Your code is missing a closing ) at the end for the Connect function. Final code should look like this:

local numbervalue = script.parent
numbervalue:GetPropertyChangedSignal(“Value”):Connect(function()
     if numbervalue.Value == 12 then
         game.Players.LocalPlayer:WaitForChild(‘PlayerGui’).Ending.Frame.Visible = true
     end
end)

Ill let you knoiw if it works!

1 Like

It didnt work

I need the “Hmm, now all I need is gasoline…” to appear along with gasoline when those pieces are placed into the ship. there are 12 pieces.

That has to do with you actually updating the NumberValue object’s value. are you updating the value? and if so, can you show me your code? The UI will only become visible when the value is equal to 12

Ive kinda scratch that, ive moved on to a new thing

You don’t need to do GetPropertyChangedSignal on the NumberValue. The Changed event of the NumberValue fires if the Value property changes.

Link for the Changed event: NumberValue | Documentation - Roblox Creator Hub

1 Like