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

Gui working in Studio but not Online?

Asked by
nicros 165
9 years ago

So ive got this inventory GUI and in studio test runs it works fine the button i have works closing and opening it and yada yada but when i test it online the button doesnt work...its color changes showing its a button but when i click it nothing opens.....

here is the script

player = game.Players.LocalPlayer

game.StarterGui:SetCoreGuiEnabled('Backpack',false)

--
local Enabled = false


function UpdateInventory()
    if Enabled == false then
        Enabled = true
        script.Parent.Frame.Visible = true
        script.Parent.Frame.CanvasSize = UDim2.new(0,0,0,20*#player.Backpack:children())
        script.Parent.Frame:ClearAllChildren()
        for i,v in pairs(player.Backpack:GetChildren()) do
            Obj1 = Instance.new('ImageButton',script.Parent.Frame)
            Obj1.Size = UDim2.new(0,60,0,60)
            Obj1.Position = UDim2.new(0,5,0,65*i-50)
            Obj1.BackgroundTransparency = 0
            Obj1.Image = v.TextureId
            Obj1.MouseButton1Down:connect(function()
                player.Character.Humanoid:UnequipTools()
                player.Character.Humanoid:EquipTool(v)
            end)
        end
    else
        Enabled = false
        script.Parent.Frame.Visible = false
    end
end

script.Parent.InvenButton.MouseButton1Down:connect(function()
    UpdateInventory()
end)

player.Backpack.Changed:connect(function()
    if Enabled == false then Enabled = true UpdateInventory() end
    if Enabled == true then Enabled = false UpdateInventory() end
end)

if you could point out what in it is keeping it from working online i would very much appreciate it :)

0
Are you using a LocalScript? Muoshuu 580 — 9y
0
yes i am....should i not be? nicros 165 — 9y
0
You should wait for the gui loads into the player. game.Players.LocalPlayer:WaitForChild("Backpack") Nickoakz 231 — 9y
0
:p sorry im a big noob at LUA....what do you mean? Is there something i need to add/change in the script? :) thanks for the replies btw nicros 165 — 9y

Answer this question