Hey there! ive been scripting around and i came to an error that I have no idea how to fix. The problem is that i am able to change a boolvalue for Equip to true but unable to change Selected boolvalue to true using .Value but they are both boolvalues. Output error was “attempt to index boolean with ‘Value’”
Both Boolvalues exists in the workspace. Any help would be great.
for i,v in pairs(script.Parent.Parent.Parent.ScrollingFrame:GetChildren()) do
if v:IsA("UIGridLayout") == false and times == 0 and v.Equip.Value == false then
v.Equip.Value = true --this had no problems
v.Selected.Value = true --this causes and error mentioned above
times = 1
else
end
end
for i,v in pairs(script.Parent.Parent.Parent.ScrollingFrame:GetChildren()) do
if v:IsA("UIGridLayout") == false and times == 0 and v.Equip == false then
v.Equip = true
v.Selected = true
times = 1
else
end
end
Hope it works. You can try, cause maybe the “Value” was a problem.
If that doesn’t work, reference both the equip and selected.Value variables in a script.
Thanks for the suggestion. I have tried both of the methods,no error outputs but when i refer to the workspace both boolValues will still remain false.
I’m pretty sure an ImageButton has a property called Selected (which is a boolean), and the script is mistaking that with the BoolValue of the same name you want to change.
All you need to do is using FindFirstChild (in this case v:FindFirstChild("Selected").Value = true) to tell the script to find a child of the object, not a property
Oh I didnt know ImageButton had a property called selected! So in order to know if its selected i could just use the Property that is already built in right?Thanks for the information!