Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

GUI is showing new tabs in studio, but not in the Player?

I'm very confused right now. I have been working on a script for a store but there has been some trouble with the testing. Inside of studio, I use play solo and it works all fine. But when I do it in the Roblox player, it doesn't work. Please help me. Here is the full script.

local Player = game.Players.LocalPlayer.PlayerGui
local Store = Player.Store
 -- Don't use parent just put the gui in StarterGUI
local StoreBut = Store.StoreBut
local MainBack = Store.MainBack
local Trails = Store.Trails
local Hats = Store.Hats
local Guns = Store.Guns

MainBack.HatsButton.MouseButton1Click:connect(function() -- Use MouseButton1Click
MainBack.Visible = false
Hats.Visible = true 

end)

MainBack.SnipersButton.MouseButton1Click:connect(function() -- Use MouseButton1Click
MainBack.Visible = false
Guns.Visible = true 

end)

MainBack.EffectsButton.MouseButton1Click:connect(function() -- Use MouseButton1Click
MainBack.Visible = false
Trails.Visible = true 

end)

Hats.Exit.MouseButton1Click:connect(function()	
Hats.Visible = false
MainBack.Visible = true
end)

Guns.Exit.MouseButton1Click:connect(function()	
Guns.Visible = false
MainBack.Visible = true
end)

Trails.Exit.MouseButton1Click:connect(function()	
Trails.Visible = false
MainBack.Visible = true
end)

Hats.Exit.MouseButton1Click:connect(function()	
Hats.Visible = false
MainBack.Visible = true
end)

Guns.Exit.MouseButton1Click:connect(function()	
Guns.Visible = false
MainBack.Visible = true
end)

MainBack.Exit.MouseButton1Click:connect(function()	
MainBack.Visible = false
StoreBut.Visible = true
end)

StoreBut.TextButton.MouseButton1Click:connect(function()	
MainBack.Visible = true
StoreBut.Visible = false
end)

1 answer

I am very confused of what this is supose to be doing... But if I were you I would use :WaitForChild() pretty much all of the time.

Example:

-- //DO NOT USE THIS
local WS = game:GetService("Workspace")
local Part = WS.Part -- VERY WRONG!

-- //BUT USE THIS METHOD
local WS = game:GetService("Workspace")
local Part = WS:WaitForChild("Part") -- Perfect!

2 comments

0

Even better, you can put a timeout value in the WaitForChild call, so it'll only wait however many seconds you give it and if it doesn't get anything by then it'll return nil.

0

@GoldenPhysics very true, but I think 5 seconds is already more than enough so in this case just leave it blank.

This discussion is preserved as it was. New answers, comments, and votes are closed.