Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I'm trying to make frames Visible and Not Visible. Does anyone know why this is breaking?

Asked by 4 years ago
Edited 4 years ago

So I have a StarterGui named Menu consisting of multiple frames and one TextButton :

Abilities, Inventory, Players, TabFrame, TravelFrame, TextButton.

Inside TabFrame: - UIListLayout set to Horizontal Layout - 4 Buttons Named: AbilitiesTab, PlayersTab, InventoryTab, TravelTab - LocalScript that contains the code at the end of this question.

The other frames inside the starterGui Menu contain nothing and are just frames with exactly the same positioning and size.

Tab Frame allows the user to click on one of the tabs, and switch to the inventory frame, abilities frame, travel frame, or players frame.

Tab Frame will always be visible but the other frames switch between what is selected.

So If I were to click the TravelTab it would switch from the starting Frame "Inventory" to the Travel Frame and make Inventory.Visible = false and TravelFrame.Visible = true.

Yes I probably should make them all Have frame at the end or not at all lol.

However for some reason the frames do not change in visibility. The buttons work correctly and change background color, text color exactly the way they should. But when trying to make the frames visible or not visible, something breaks in the code.

Here is the code! Thank you!

local TravelFrame = game.StarterGui.Menu.TravelFrame
local Inventory = game.StarterGui.Menu.Inventory
local Abilities = game.StarterGui.Menu.Abilities
local Players = game.StarterGui.Menu.Players
local TravelTabButton = script.Parent.TravelTab
local InventoryButton = script.Parent.InventoryTab
local AbilitiesButton = script.Parent.AbilitiesTab
local PlayersButton = script.Parent.PlayersTab
local ActiveTab = Instance.new("Frame")
local ActiveTabButton = Instance.new("TextButton")

ActiveTabButton = InventoryButton
ActiveTab = Inventory

script.Parent.TravelTab.MouseButton1Click:connect(function()
  -- Sets The last active tab to default non active color (White)
  ActiveTabButton.BackgroundColor3 = Color3.new(255, 255, 255)
  ActiveTabButton.TextColor3 = Color3.new(0 , 0, 0)
  -- Once last active tab colors are set, Sets ActiveTabButton to new active Tab and sets colors to black (Active)
  ActiveTabButton = TravelTabButton
  ActiveTabButton.BackgroundColor3 = Color3.new(0, 0, 0)
  ActiveTabButton.TextColor3 = Color3.new(255, 255, 255)

  -- Sets Last Active Page/Frame to invisible and switches ActiveTab to new active page.
  ActiveTab.Visible = false
  ActiveTab = TravelFrame
  ActiveTab.Visible = true
end)

script.Parent.InventoryTab.MouseButton1Click:connect(function()
  -- Sets The last active tab to default non active color (White)
  ActiveTabButton.BackgroundColor3 = Color3.new(255, 255, 255)
  ActiveTabButton.TextColor3 = Color3.new(0 , 0, 0)
  -- Once last active tab colors are set, Sets ActiveTabButton to new active Tab and sets colors to black (Active)
  ActiveTabButton = InventoryButton
  ActiveTabButton.BackgroundColor3 = Color3.new(0, 0, 0)
  ActiveTabButton.TextColor3 = Color3.new(255, 255, 255)

  -- Sets Last Active Tab to invisible and switches ActiveTab to new active page.
  ActiveTab.Visible = false
  ActiveTab = Inventory
  ActiveTab.Visible = true
end)

script.Parent.PlayersTab.MouseButton1Click:connect(function()
  -- Sets The last active tab to default non active color (White)
  ActiveTabButton.BackgroundColor3 = Color3.new(255, 255, 255)
  ActiveTabButton.TextColor3 = Color3.new(0 , 0, 0)
  -- Once last active tab colors are set, Sets ActiveTabButton to new active Tab and sets colors to black (Active)
  ActiveTabButton = PlayersButton
  ActiveTabButton.BackgroundColor3 = Color3.new(0, 0, 0)
  ActiveTabButton.TextColor3 = Color3.new(255, 255, 255)

  -- Sets Last Active Tab to invisible and switches ActiveTab to new active page.
  ActiveTab.Visible = false
  ActiveTab = Inventory
  ActiveTab.Visible = true
end)

script.Parent.AbilitiesTab.MouseButton1Click:connect(function()
  -- Sets The last active tab to default non active color (White)
  ActiveTabButton.BackgroundColor3 = Color3.new(255, 255, 255)
  ActiveTabButton.TextColor3 = Color3.new(0 , 0, 0)
  -- Once last active tab colors are set, Sets ActiveTabButton to new active Tab and sets colors to black (Active)
  ActiveTabButton = AbilitiesButton
  ActiveTabButton.BackgroundColor3 = Color3.new(0, 0, 0)
  ActiveTabButton.TextColor3 = Color3.new(255, 255, 255)

  -- Sets Last Active Tab to invisible and switches ActiveTab to new active page.
  ActiveTab.Visible = false
  ActiveTab = Inventory
  ActiveTab.Visible = true
end)

I also tried to just open a frame without the complex code and with a simple TextButton. I put the local script in the textbutton and

script.Parent.MouseButton1Click:connect(function()
    -- Just an example. This did not work either.
    someFrame.Visible = true
    textButton.Visible = false
end)
0
I am given no errror. The frames just aren't changing from visible to not visible. SethHeinzman 284 — 4y
1
lol replace game.StarterGui to player.PlayerGui WillBe_Stoped 71 — 4y
0
maybe replace every color3.new() with color3.fromRGB(), (e.g Color3.fromRGB(50,30,10) would be Color3.new(50/255,30/255,10/255), maybe change it because it wont change the color) Kriscross102 118 — 4y
0
LOL thank you. I can't believe I forgot about that. SethHeinzman 284 — 4y

1 answer

Log in to vote
1
Answered by 3 years ago

Figured I would put the answer here for all to see, instead of in the comments. You put StarterGui instead of PlayerGui.

Pretty much what happens when you have Gui stuff in the StarterGui is that at the start of the game, the stuff is cloned into the players PlayerGui. So when trying to change Guis for the player always use game.Players.LocalPlayer.Playergui or player.PlayerGui depending on if you set player to the right path.

Ad

Answer this question