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

[SOLVED] Why is my shop gui not appearing?

Asked by 8 years ago

So I'm working on a game that uses ClickDetect on a part to open my shop. It works perfectly in play solo, but as soon as I publish it and play it online the shop Gui won't open.

Here is the script:

script.Parent.MouseClick:connect(function(playerWhoClicked)
    if game.Players.LocalPlayer.PlayerGui:FindFirstChild("Shop") == nil then
        game.StarterGui.Shop:Clone().Parent = game.Players.LocalPlayer.PlayerGui
    end
  game.Players.LocalPlayer.PlayerGui.Shop.Background.Visible = true
end)
0
Is the local script in Workspace? That would be the problem. PreciseLogic 271 — 8y
0
Yeah. Where would I need to put it for it to work? kell1300 0 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago

Make Sure It's A Local Script!

On line 5, try getting rid of Background and just using Visible. game.Players.LocalPlayer.PlayerGui.Shop.Visible = true. Also, you don't need lines 2-4 because you can be assured that roblox will copy everything from the StarterGui at the beginning of the game. You might also want to check if the Shop is already visible. Example,

script.Parent.MouseClick:connect(function()
    if game.Players.LocalPlayer.PlayerGui.Shop.Visible == false then
        game.Players.LocalPlayer.PlayerGui.Shop.Visible = true
    else
        game.Players.LocalPlayer.PlayerGui.Shop.Visible = false
    end
end)

I hope this works. Good Luck!

0
It didn't work sadly. kell1300 0 — 8y
0
Oh, I forgot to remove the Background User#11440 120 — 8y
0
I'm an idiot. I was missing an end. User#11440 120 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

I solved it. I just ran a local script from the StarterGui.

0
Good for you! User#11440 120 — 8y

Answer this question