BoolValue not changing

My problem is small and simple.
I was working on an accessory shop where i wanted to make it so that when the boolValue inside of an image button is set to true, the image button will be visible.
This is the code that changes the value

Here’s the code where i set it to true.
Know that it is initially set to false.

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Parent.Parent.Inventory.Inv.InvBasic.BuyLolita.SkirtSkript.Bought.Value = true
	script.Parent.Parent.Visible = false
end)

I know that this directory is perfect and there are no mistakes there.
When i see the value when the script is run, it does not change.
I would really appreciate help.

1 Like

Have you done any debugging? Such as adding print() functions in places to log what parts are working correctly and what are not? Another issue could be when you are viewing the boolean value during run-time. You need to make sure you are viewing it client-side, not server-side (due to filteringEnabled).

1 Like

Yeah your script is pretty messed up

Like why that second long line when you can just do this

--Basically the same script except it has less characters and has a higher chance for it to work
script.Parent.MouseButton1Click:Connect(function()
	script.Bought.Value = true
    script.Parent.Parent.Visible = false
end)

Hope that helped and happy coding!

2 Likes

Ive found out that my attribute changed script is not running.
Do you know any reason for why that might be happening?

Can you provide your code for it so I can have a look?

1 Like

script.Bought.AttributeChanged:Connect(function()
	print("HI")
	script.Bought.Value = true
end)
script.Parent.MouseButton1Click:Connect(function()
	script.Parent.AddOrRemove.Visible = true
end)

The HI is not getting printed

Did you check it in PlayerGui or you checked it in StarterGui?

1 Like

Starter gui. But the bool only changes in client side.

Thats because the attribute isnt changing you probably need to call a new event

1 Like

You are suppose to be checking it in PlayerGui. Check it again and see if it changes.

1 Like

You need to change the AttributeChanged to a GetPropertyChangedSignal("Value") so that it will fire when the value is changed.

Edit: For future reference and anyone revisiting this post, the Value of an instance variable is a property, not and attribute - hence why AttributeChanged didn’t work. You also have to specify what property it is using to trigger the event, so in this case the "Value" string was added to the arguments.

Glad this helped you, and good luck with your future endeavours.

3 Likes

Even if i check in the player gui, the image button is still not visible

Ill try that and if it works ill put your last post as solution

1 Like