I made an intro and a Gun shop Gui, Obviously they're both Screen Gui's, but anyways i have been trying to make Gun shop Gui invisible until the intro is over and here is what i came up with
game.StarterGui.GunShopGui.Box.Visible = false game.starterGui.GunShopGui.OpenAndClose.Visible = false wait(1) script.Parent.Visible = true script.Parent.Parent.Music:Play() script.Parent.Text = "[ Loading ]" wait(1) script.Parent.Text = "[ 5% ]" wait(0.15) script.Parent.Text = "[ 7% ]" wait(0.15) script.Parent.Text = "[ 9% ]" wait(0.15) script.Parent.Text = "[ 20% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 34% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 60% ]" wait(0.15) script.Parent.Text = "[ 60% ]" wait(0.15) script.Parent.Text = "[ 74% ]" wait(0.15) script.Parent.Text = "[ 83% ]" wait(0.15) script.Parent.Text = "[ 83% ]" wait(0.15) script.Parent.Text = "[ 83% ]" wait(0.15) script.Parent.Text = "[ 97% ]" wait(1) script.Parent.Text = "[ 100% ]" wait(0.05) script.Parent.Transparency = 0.05 wait(0.05) script.Parent.Transparency = 0.10 wait(0.05) script.Parent.Transparency = 0.15 wait(0.05) script.Parent.Transparency = 0.20 wait(0.05) script.Parent.Transparency = 0.25 wait(0.05) script.Parent.Transparency = 0.30 wait(0.05) script.Parent.Transparency = 0.35 wait(0.05) script.Parent.Transparency = 0.40 wait(0.05) script.Parent.Transparency = 0.45 wait(0.05) script.Parent.Transparency = 0.50 wait(0.05) script.Parent.Transparency = 0.55 wait(0.05) script.Parent.Transparency = 0.60 wait(0.05) script.Parent.Transparency = 0.65 wait(0.05) script.Parent.Transparency = 0.70 wait(0.05) script.Parent.Transparency = 0.75 wait(0.05) script.Parent.Transparency = 0.80 wait(0.05) script.Parent.Transparency = 0.85 wait(0.05) script.Parent.Transparency = 0.90 wait(0.05) script.Parent.Transparency = 0.95 wait(0.05) script.Parent.Transparency = 1.00 wait(.1) script.Parent.Parent.Music:Stop() wait(.1) game.StarterGui.GunShopGui.Box.Visible = false game.starterGui.GunShopGui.OpenAndClose.Visible = false
The intro worked fine after that but the Gun shop Gui never appeared, Is there any way i could fix this? And just some extra Information , that might or might not be helpful but both Screen Gui's are by them self not, with one Gui inside another one.
I think the whole script could be cleaned up.
First. You will never get your Shop back if you assign your gui's visiblility property as false
game.StarterGui.GunShopGui.Box.Visible = false game.starterGui.GunShopGui.OpenAndClose.Visible = false --The rest of the script game.StarterGui.GunShopGui.Box.Visible = true game.starterGui.GunShopGui.OpenAndClose.Visible = true
Second. You are making the changes above on theStarterGui
, or in a "GuiStorage", as I call it. So you will only get the results once you respawn you character. To prevent this, you can use the script.Parent
technique as you did on the intro. Assuming the intro is like script.Parent.Parent.Parent
inside the StarterGui (if not, correct by yourself)
script.Parent.Parent.Parent.GunShopGui.Box.Visible = false script.Parent.Parent.Parent.GunShopGui.OpenAndClose.Visible = false --The rest of the script script.Parent.Parent.Parent.GunShopGui.Box.Visible = true script.Parent.Parent.Parent.GunShopGui.OpenAndClose.Visible = true
And finally, you can make the transparency system look more fluid. Instead of writing lots and lots of lines, you can just use a while
or a for
loop:
INSTEAD OF:
script.Parent.Transparency = 0.05 wait(0.05) script.Parent.Transparency = 0.10 wait(0.05) script.Parent.Transparency = 0.15 wait(0.05) script.Parent.Transparency = 0.20 wait(0.05) script.Parent.Transparency = 0.25 wait(0.05) script.Parent.Transparency = 0.30 wait(0.05) script.Parent.Transparency = 0.35 wait(0.05) script.Parent.Transparency = 0.40 wait(0.05) script.Parent.Transparency = 0.45 wait(0.05) script.Parent.Transparency = 0.50 wait(0.05) script.Parent.Transparency = 0.55 wait(0.05) script.Parent.Transparency = 0.60 wait(0.05) script.Parent.Transparency = 0.65 wait(0.05) script.Parent.Transparency = 0.70 wait(0.05) script.Parent.Transparency = 0.75 wait(0.05) script.Parent.Transparency = 0.80 wait(0.05) script.Parent.Transparency = 0.85 wait(0.05) script.Parent.Transparency = 0.90 wait(0.05) script.Parent.Transparency = 0.95 wait(0.05) script.Parent.Transparency = 1.00 wait(.1) script.Parent.Parent.Music:Stop() wait(.1)
Use this:
while script.Parent.Transparency < 1 do --while the label's transparency value is lower than 1, or else, while you can see the label script.Parent.Transparency = script.Parent.Transparency + 0.05 -- add some transpareny to the label wait() --fluid process and crash prevent end wait(.1) script.Parent.Parent.Music:Stop() wait(.1)
Or this:
for i = 1,20 do -- because 0.05*20 = 1 script.Parent.Transparency = script.Parent.Transparency + 0.05 -- add some transpareny to the label wait() --fluid process end wait(.1) script.Parent.Parent.Music:Stop() wait(.1)
And what about this loading lines? Can't we do the same? Obviously we can.
INSTEAD OF
script.Parent.Text = "[ 5% ]" wait(0.15) script.Parent.Text = "[ 7% ]" wait(0.15) script.Parent.Text = "[ 9% ]" wait(0.15) script.Parent.Text = "[ 20% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 34% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 60% ]" wait(0.15) script.Parent.Text = "[ 60% ]" wait(0.15) script.Parent.Text = "[ 74% ]" wait(0.15) script.Parent.Text = "[ 83% ]" wait(0.15) script.Parent.Text = "[ 83% ]" wait(0.15) script.Parent.Text = "[ 83% ]" wait(0.15) script.Parent.Text = "[ 97% ]" wait(1) script.Parent.Text = "[ 100% ]"
Use in pairs
function
local l = {5, 7, 9, 20, 35, 34, 35, 35, 35, 35, 35, 60, 60, 74, 83, 83, 83, 97, 100} for i,v in pairs(l) do script.Parent.Text = "[ "..v.."% ]" wait (0.15) end
Whole script
local l = {5, 7, 9, 20, 35, 34, 35, 35, 35, 35, 35, 60, 60, 74, 83, 83, 83, 97, 100} script.Parent.Parent.Parent.GunShopGui.Box.Visible = false script.Parent.Parent.Parent.GunShopGui.OpenAndClose.Visible = false wait(1) script.Parent.Visible = true script.Parent.Parent.Music:Play() script.Parent.Text = "[ Loading ]" wait(1) -- the in pairs loop for i,v in pairs(l) do script.Parent.Text = "[ "..v.."% ]" wait (0.15) end --loop 1 (choose one) while script.Parent.Transparency < 1 do --while the label's transparency value is lower than 1, or else, while you can see the label script.Parent.Transparency = script.Parent.Transparency + 0.05 -- add some transpareny to the label wait() --fluid process and crash prevent end --loop 2 (choose one) for i = 1,20 do -- because 0.05*20 = 1 script.Parent.Transparency = script.Parent.Transparency + 0.05 -- add some transpareny to the label wait() --fluid process end wait(.1) script.Parent.Parent.Music:Stop() wait(.1) script.Parent.Parent.Parent.GunShopGui.Box.Visible = true script.Parent.Parent.Parent.GunShopGui.OpenAndClose.Visible = true
Do you see? If you try to learn something more, you can reduce your script lines!! In this case, the lines were reduced in more than 50% !!!
It's a mistake on your end!
game.StarterGui.GunShopGui.Box.Visible = false game.starterGui.GunShopGui.OpenAndClose.Visible = false wait(1) script.Parent.Visible = true script.Parent.Parent.Music:Play() script.Parent.Text = "[ Loading ]" wait(1) script.Parent.Text = "[ 5% ]" wait(0.15) script.Parent.Text = "[ 7% ]" wait(0.15) script.Parent.Text = "[ 9% ]" wait(0.15) script.Parent.Text = "[ 20% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 34% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 35% ]" wait(0.15) script.Parent.Text = "[ 60% ]" wait(0.15) script.Parent.Text = "[ 60% ]" wait(0.15) script.Parent.Text = "[ 74% ]" wait(0.15) script.Parent.Text = "[ 83% ]" wait(0.15) script.Parent.Text = "[ 83% ]" wait(0.15) script.Parent.Text = "[ 83% ]" wait(0.15) script.Parent.Text = "[ 97% ]" wait(1) script.Parent.Text = "[ 100% ]" wait(0.05) script.Parent.Transparency = 0.05 wait(0.05) script.Parent.Transparency = 0.10 wait(0.05) script.Parent.Transparency = 0.15 wait(0.05) script.Parent.Transparency = 0.20 wait(0.05) script.Parent.Transparency = 0.25 wait(0.05) script.Parent.Transparency = 0.30 wait(0.05) script.Parent.Transparency = 0.35 wait(0.05) script.Parent.Transparency = 0.40 wait(0.05) script.Parent.Transparency = 0.45 wait(0.05) script.Parent.Transparency = 0.50 wait(0.05) script.Parent.Transparency = 0.55 wait(0.05) script.Parent.Transparency = 0.60 wait(0.05) script.Parent.Transparency = 0.65 wait(0.05) script.Parent.Transparency = 0.70 wait(0.05) script.Parent.Transparency = 0.75 wait(0.05) script.Parent.Transparency = 0.80 wait(0.05) script.Parent.Transparency = 0.85 wait(0.05) script.Parent.Transparency = 0.90 wait(0.05) script.Parent.Transparency = 0.95 wait(0.05) script.Parent.Transparency = 1.00 wait(.1) script.Parent.Parent.Music:Stop() wait(.1) game.StarterGui.GunShopGui.Box.Visible = true -- You set this to false, not true game.starterGui.GunShopGui.OpenAndClose.Visible = true -- Same here! true not false!