So.. I have problem with my script as you can see int title.
I've been trying to do system in my gui that will show category that you clicked on or change showed category to category that you clicked on.(Yes I know it's hard to understand but if you see my code you should know what's going on)
Here's the script in both categories and link to imgur for photo of my starterGui folder.
Code:
local Category = script.Parent.Parent.Parent.Value.Value local Name = script.Parent.Name function onclick() if script.Parent.Parent.Parent:FindFirstChild(Name).Visible == false and Category ~= script.Parent then script.Parent.Parent.Parent:FindFirstChild(Name).Visible = true Category = script.Parent else script.Parent.Parent:FindFirstChild(Category).Visible = false script.Parent.Parent.Parent:FindFirstChild(Name).Visible = true Category = script.Parent end end script.Parent.MouseButton1Click:connect(onclick)
;
Link:
If doesn't work then link here: https://imgur.com/V1e2RTw
Also... How i can change those modern but ugly icons in Studio to old design?
[edit] here's that error:
Players.Ambulans1234.PlayerGui.buildUI.Categories.Beds.GuiClick:9: attempt to index nil with 'Visible' - Server - GuiClick:9
I wouldn't recommend defining Category outside of your function; it doesn't update as the value updates. To simplify it:
For example, say I have this setup: https://imgur.com/a/Z2IHhGe
The Catagory value gets changed when the ChangeValue button is pressed; it will cycle through two strings "Test1" and "Test2"
With the content of the Controller script being:
local PrintValueButton = script.Parent.PrintValue local Catagory = script.Parent.Catagory.Value function onClick() print(Catagory) end PrintValueButton.MouseButton1Click:Connect(onClick)
when the PrintValue button gets pressed: the script will constantly print "Test1", because the Catagory variable has already been set, and will not change
.. whereas if we assign the Catagory variable inside the function:
local PrintValueButton = script.Parent.PrintValue function onClick() local Catagory = script.Parent.Catagory.Value print(Catagory) end PrintValueButton.MouseButton1Click:Connect(onClick)
the script will print the Catagory value as it is when the button got called.
Hope this explains what the issue might be, shoot a comment if you think otherwise!