✓ Accepted answer
Please read this short article excerpt.
####TL;DR:
StarterGui is not the authentic household of the GUI Objects, to actively modify the local User Interface, you have to access the PlayerGui container of a Player Object. Fortunately, the .Touched signal's Hit parameter can be used to pull a Player Object from the Instance of contact, which is a piece of your Character Rig.
local Players = game:GetService("Players")
local Part = script.Parent
local function OpenGui(Hit)
local Humanoid = Hit.Parent:FindFirstChildOfClass("Humanoid")
if (Humanoid) then
local Player = Players:GetPlayerFromCharacter(Hit.Parent)
if (Player) then
local PlayerGui = Player:WaitForChild("PlayerGui")
local Shop = PlayerGui:WaitForChild("Shop")
local Frame = Shop:WaitForChild("Frame")
Frame.Visible = not (Frame.Visible)
end
end
end
Part.Touched:Connect(OpenGui)
If this works for you, don't forget to accept this answer!
14 comments
It works, but only once. How would I make it so it works multiple times?
What do you mean only once?
If I step on it, then close the gui, it doesn't pop up again when I step on it.
How are you closing the GUI
I have an X Button script that makes the GUI invisible
Make sure you're not making the Shop Gui invisible. Otherwise this will also cause the Frame to disappear regardless of the visibility.
Then how would I close it without using the X Button or making it invisible?
Are you gonna respond?
alright im going to bed see u tommorow if you answer
Try the code above, check the output if it doesn’t work.
hang on
wait nvm i know what u mean)
i get nothing in the output when i open or close the gui
can we solve this tommorow? I need to go to bed.