Why does this LocalScript with a NumberValue not work?

I have 0 errors when this runs. Help.

local frame = script.Parent.Parent.Parent.Frame

script.Parent.MouseButton1Click:Connect(function()
	if frame.MoneyValue.Value >= 1500 then
		script.Parent.BackgroundTransparency = 1
		script.Parent.Parent.Visible = false
	elseif frame.MoneyValue.Value < 1500 then
		script.Parent.BackgroundTransparency = 0
	end
end)
1 Like

if frame.MoneyValue.Value >= 1500 then

is saying is this greater then or equal to 1500 …
Then you go on to elseif it’s == to 1500 …

It will never hit that part of the code.
if it is 1500 it will again use the top if and bypass the lower if.

Maybe something like this …

local frame = script.Parent.Parent.Parent.Frame

script.Parent.MouseButton1Click:Connect(function()
	if frame.MoneyValue.Value >= 1500 then
		script.Parent.BackgroundTransparency = 0
		script.Parent.Parent.Visible = false
	else
		script.Parent.BackgroundTransparency = 1
	end
end)

Nope. Still no errors and doesn’t work.

What is this, what are you looking to do with it … exactly.
Show me your file structure … explain the task fully.

I personally do not like to use Parent so much. Them can be define and called directly.
You’re stating .BackgroundTransparency = 0 and then Visible = false
0 would be show the GUI. 1 would be hide the GUI with Transparency.
(well the background anyways)

Right now, the thing the script does is a placeholder, but I’m trying to make a shop where you can buy tools. I have a LocalScript checking to see if you press a button, and if you have more or equal to/less than the amount of 1500. Here is my explorer.
image
I am only using Parent a lot because of PlayerGui and I don’t want to mess around with that.

Also, .BackgroundTransparency and .Visible are not the same thing and that’s (from what I know of) not breaking the script. Also my problem is that the GUI is not going invisible.

yes I know that … just trying to make sense of what you’re doing …
So you want it to be visible only if they have the “cash” to buy it?

I want it to be visible to everyone, but if the player has enough “money” than I want the LocalScript to run.

sorry for saying yes on accident lol idk what im doing as well

Well nothing will happen till they click on it. So they would see it no matter what at 1st.

local frame = script.Parent.Parent.Parent.Frame
script.Parent.MouseButton1Click:Connect(function()
	if frame.MoneyValue.Value >= 1500 then
		
		print("1")
		script.Parent.BackgroundTransparency = 0
		script.Parent.Parent.Visible = true
	else
		
		print("2")
		script.Parent.BackgroundTransparency = 1
		script.Parent.Parent.Visible = false
	end
end)

testing with this … is this even close.

Let’s take this to PMs so I can take a good look at that GUI myself.

No need for PMs, this works! Thanks.

1 Like

Thx god …lol, have to admit you lost me on what you wanted to do here.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.