Issue with shop & pad

Error:

Trying to make it so that when you touch the shoppad it opens the shop gui. ran into a small bug, and it wont open. Any ideas?

(I double checked all the paths, everything looks fine visually.)

I know how to make it so it pops up for you and you only unless someone else does it for themself, though it’ll take me a bit to answer for you, so if you want you can add me on discord Dem0#1776

Are you spawning in on the pad? If the paths are 100% existent only thing I can think of is it calling before the Gui is loaded. Could try defining it as a variable using :WaitForChild() and see if that makes a difference.

local Gui = game.Players:GetPlayerFromCharacter(hit.parent):PlayerGui:WaitForChild("ShopGui")
Gui.Background.Visible = true

You’ll need a remote event for it to show up for you and you only if you’ve touched the part.

You need to wait for the player to load in, maybe?
game.Players.PlayerAdded:Connect(function(Player)
–COde
end)
this will only fire once the player is loaded.

The code is in a localscript, should I move it to a regular script and fire(client) a remote event?

Not necessarily, if he’s configuring the player gui, then it’s only going to show for that player.

@notMundaze, you don’t really need the humanoid for what you are trying to do, instead you can set your GetPlayerFromCharacter to a player variable, and reference the gui from there.

local player = game.Players:GetPlayerFromCharacter(hit.Parent)

if player then 
     local playerUI = player:FindFirstChild("PlayerGui")

     if playerUI then 
        playerUI:FindFirstChild("ShopGui").Background.Visible = true
     end
end

Just saw your last message, this should be in a script to correct the .Touched event, not a local script. You can go with firing a remote event, or configuring the player GUI, whatever suits best to you.

Are you sure the “ShopGui” object is in the PlayerGui?

playerUI:FindFirstChild("ShopGui"):FindFirstChild("Background").Visible = true,

At this point, it’s best to go with a remote event.

It would have to be, considering the error was thrown on the background part, meaning it found the ShopGui, but not the Background frame

The error wasn’t thrown for the background. It was thrown for the ShopGui. Attempt to index nil with background is the same thing as doing nil.Background (where nil is an actual nil value). Hes basically trying to reference an object called background from nothing (nil).

Ah yeah my bad, didn’t see that one.

Unless it’s out of the PlayerGui, which would probably be the reason, or the player somehow returned nil

Its not either of those otherwise the error would be attempt to index PlayerGui with nil or index shopGUi with nil. His original error “ShopGui is not a valid member of PlayerGui”, means the ShopGui object doesn’t exist in the PlayerGui.

Which is why I asked him to confirm that the shopGui is indeed in the PlayerGui.

1 Like

shopgui is in startergui therefore it will be in playergui no matter what

When your testing in studio. Can you open up the players PlayerGui and screenshot the contents in it?

Okay overnight I managed to get it working. Although you can only open it once.

It’s a problem with the debounce. – NEVERMIND, it’s not. I tested it, still only lets you open it once.

I tried a bunch of scripts, none seem to be working.

Got it working aha. Thanks all.