I have no clue what I am doing wrong please help me, thanks
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame.Visible = true |
3 | if script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame.Visible = = true then script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame.Visible = false |
4 | end |
5 | end |
Do you want help with the script? I got the script right here for you:
1 | local ShopFrame = script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame --For it to be faster |
2 | script.Parent.MouseButton 1 Click:connect( function () |
3 | ShopFrame.Visible = not ShopFrame.Visible |
4 | end ) |
You were constantly updating the Frame to be visible everytime someone clicked the button by including it in the function. This script fixes that.
1 | local ShopFrame = script.Parent.Parent.Parent.Parent.ShopFrame.ShopFrame --Indexes placement of Frame |
2 | ShopFrame.Visible = true --Here we can change the Frame to be visible during the start |
3 | script.Parent.MouseButton 1 Click:Connect( function () --When a player hits a button |
4 | if ShopFrame.Visible = = true then --If visible then |
5 | ShopFrame.Visible = false --Change it back to false |
6 | elseif ShopFrame.Visible = = false then --If invisible then |
7 | ShopFrame.Visible = true --Change it back to true |
8 | end |
9 | end ) |
If this helped, be sure to accept my answer!