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

How to make my inventory GUI to be already closed while playing the game ?

Asked by 3 years ago

So , my problem is like , i ve got an inventory GUI , but when i hit play , it s already open and i have to close it myself everytime , what should i do to make it already closed?

here is the whole script

local imageLabel = script.Parent

local player = game.Players.LocalPlayer

local playerInventory = player:WaitForChild('Inventory')

local openButton = imageLabel.Open
local isOpen = true

local crystal1 = playerInventory:FindFirstChild('Blue')
local crystal1Label = imageLabel.Amount1

local crystal2 = playerInventory:FindFirstChild('Red')
local crystal2Label = imageLabel.Amount2

local crystal3 = playerInventory:FindFirstChild('Green')
local crystal3Label = imageLabel.Amount3

local crystal4 = playerInventory:FindFirstChild('Yellow')
local crystal4Label = imageLabel.Amount4

local crystal5 = playerInventory:FindFirstChild('Pink')
local crystal5Label = imageLabel.Amount5

local crystal6 = playerInventory:FindFirstChild('Black')
local crystal6Label = imageLabel.Amount6

crystal1.Changed:Connect(function()
    crystal1Label.Text = crystal1.Value
end)

crystal2.Changed:Connect(function()
    crystal2Label.Text = crystal2.Value
end)

crystal3.Changed:Connect(function()
    crystal3Label.Text = crystal3.Value
end)

crystal4.Changed:Connect(function()
    crystal4Label.Text = crystal4.Value
end)

crystal5.Changed:Connect(function()
    crystal5Label.Text = crystal5.Value
end)

crystal6.Changed:Connect(function()
    crystal6Label.Text = crystal6.Value
end)


openButton.MouseButton1Click:Connect(function()
    if isOpen then
        imageLabel:TweenPosition(UDim2.new(-0.2, 0, 0.049, 0), "Out", "Quad", 1, true)
    else    
        imageLabel:TweenPosition(UDim2.new(0, 0, 0.049, 0), "Out", "Quad", 1, true) 
    end
    isOpen = not isOpen
end)

1 answer

Log in to vote
0
Answered by 3 years ago

in the script, make it so the inventory is not visible by doing this is an example don't use this

script.Parent.Visible = false
Ad

Answer this question