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
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)
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)
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)```
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)```
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)