Help with Shop System

Hello I was looking for answers on how to edit this script

using the (While true do ) it has it so when its “Checked” the frame called “None” stays open how would I make it so it only opens up the frame when the player clicks on the button instead of it always being open

while true do
	if script.Parent.Parent.HasBought.Value == true then
		script.Parent.Text = "Equip"
		script.Parent.Parent.Parent.None.Visible = true
	else
	script.Parent.Text = "Cost:"..script.Parent.Parent.Cost.Value	
	end
wait(0.1)
end

2 Likes

This should help,

 local button =  --replace with button parent
    button.MouseButton1Down(function()
    	-- code
    end)
1 Like

This what you’ve meant? it seems to still not work

local button = script.Parent.Parent.CostShowText
	button.MouseButton1Down(function()
while true do
		if script.Parent.Parent.HasBought.Value == true then
			script.Parent.Text = "Equip"
			script.Parent.Parent.Parent.None.Visible = true
		else
			script.Parent.Text = "Cost:"..script.Parent.Parent.Cost.Value	
		end
		wait(0.1)
	end
end)
1 Like

What he meant was

local button = script.Parent.Parent.CostShowText
button.MouseButton1Down(function()
while true do
if script.Parent.Parent.HasBought.Value == true then
script.Parent.Text = “Equip”
script.Parent.Parent.Parent.None.Visible = true
else
script.Parent.Text = “Cost:”…script.Parent.Parent.Cost.Value
end
wait(0.1)
end
end)

1 Like

Ive done that but the UI doesn’t show up now when I click the button

1 Like

try this

local button = script.Parent.Parent.CostShowText
button.MouseButton1Down:Connect(function()
if script.Parent.Parent.HasBought.Value == true then
script.Parent.Text = “Equip”
script.Parent.Parent.Parent.None.Visible = true
else
script.Parent.Text = “Cost:”…script.Parent.Parent.Cost.Value
end
wait(0.1)
end
end)```
1 Like

No it still doesn’t open the next UI

1 Like

can you send the output message
(open it by opening up “view” → “output”

1 Like

Its empty 0 errors it just doesn’t show up but if I go into the Players GUI and click visible on the UI it opens up

1 Like

are you sure its the correct amount of .parents?

1 Like

Yes im sure I’ve checked at least 5 times

1 Like

Try this

button.MouseButton1Click:Connect(function()
if script.Parent.Parent.HasBought.Value == true then
script.Parent.Text = “Equip”
script.Parent.Parent.Parent.None.Visible = true
else
script.Parent.Text = “Cost:”…script.Parent.Parent.Cost.Value
end
wait(0.1)
end
end)```
1 Like

Well, If your using a bool value or something, you should use getpropertychangedsignal instead of using a loop. Loops can cause lag to your game which isn’t what you’d want. You should make the frame “None” not visible until the value “HasBought” is true.

Your script would look somewhat like this:

local HasBought = script.Parent.Parent.HasBought

HasBought:GetPropertyChangedSignal("Value"):Connect(function()
	if HasBought.Value == true then
		script.Parent.Text = "Equip"
		script.Parent.Parent.Parent.None.Visible = true
	else
		script.Parent.Text = "Cost:"..script.Parent.Parent.Cost.Value	
	end
end)

Hope this helps! :slight_smile:

1 Like

Im trying to make it so it only shows the None frame if they’ve clicked it not just so it opens up automatically

1 Like

Would this help at all?

local HasBought = script.Parent.Parent.HasBought

script.Parent.MouseButton1Click:Connect(function()
	if HasBought.Value == true then
		script.Parent.Text = "Equip"
		script.Parent.Parent.Parent.None.Visible = true
	else
		script.Parent.Text = "Cost:"..script.Parent.Parent.Cost.Value	
	end
end)

You’d have to change the mouse click function to the button running this function.

1 Like

so now the cost doesnt work and the frame still dont shoe up

1 Like

Did you change script.Parent on the click function to the button?

1 Like

script.Parent.Parent.CostShowText.MouseButton1Click:Connect(function()???

1 Like

That wouldn’t work as it will be trying to get you the mouse or something.

1 Like

I’m just reading from what yall are saying… :confused: