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

it says "screengui not a valid member of player gui?

Asked by 2 years ago
Edited 2 years ago

I used a local script here is the code:

local open = game.Workspace.openPart local close = game.Workspace.closePart local frame = script.Parent local closeButton = frame.closeButton

frame.Visible = false

local function shopMenu(otherPart) local player = game.Players:FindFirstChild(otherPart.Parent.Name)

if player then 
    player.PlayerGui.Shop_GUI.Shop.Visible = true 
    player.Character.Humanoid.WalkSpeed = 0
end

end

local function closeMenu() local player = game.Players.LocalPlayer player.PlayerGui.Shop_GUI.Shop.Visible = false player.Character.HumanoidRootPart.CFrame = CFrame.new(close.Position.X,close.Position.Y + 3,close.Position.Z) player.Character.Humanoid.WalkSpeed = 16 end

open.Touched:Connect(shopMenu) closeButton.MouseButton1Click:Connect(closeMenu)

btw where it says "screengui not a valid member of player gui" is in output

2 answers

Log in to vote
0
Answered by 2 years ago

dude from what i understand you want a gui to be opened as soon as you relate it to a part right if so use:

in StarterGui create a local script and paste the code below remember to leave your gui in properties with the frame disabled because the script will activate it and well this is a very simple script I hope I could help you if not I'm sorry.

Local player = game:GetService("Players").LocalPlayer
Local shop = workspace.YOUR TOUCH PART GO HERE

Shop.Touched:Connect(Function(hit)
 if hit.Parent == Player.Character then
Script.Parent.YOURGUINAME.Frame.Visible = true
End
End)
0
there is a blue line under function and hit and its not working because of that legobuddie1 0 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

Fixed code

local open = game.Workspace.openPart 
local close = game.Workspace.closePart 
local frame = script.Parent 
local closeButton = frame.closeButton

frame.Visible = false

local function shopMenu(otherPart) 
    local player = game.Players:FindFirstChild(otherPart.Parent.Name) 

    if player then 
        player.PlayerGui.Shop_GUI.Shop.Visible = true 
        player.Character.Humanoid.WalkSpeed = 0
    end
end

local function closeMenu() 
    local player = game.Players.LocalPlayer 
    player.PlayerGui.Shop_GUI.Shop.Visible = false 
    player.Character.HumanoidRootPart.CFrame = CFrame.new(close.Position.X,close.Position.Y + 3,close.Position.Z) 
    player.Character.Humanoid.WalkSpeed = 16
end

open.Touched:Connect(shopMenu) 
closeButton.MouseButton1Click:Connect(closeMenu)

What was the problem?

The problem was on line 19.

You did this

player.PlayerGui.ScreenGui.Shop.Visible = false

I think it should be this

player.PlayerGui.Shop_GUI.Shop.Visible = false 

If this doesn't work then you need to screenshot your hierarchy and send it to me.

0
This is what it says when I walk on the part btw it says this in output legobuddie1 0 — 2y
0
This is what it says in output when I walk on the part "Shop_GUI is not a valid member of PlayerGui "Players.Legobuddie1.PlayerGui" legobuddie1 0 — 2y
0
do you have a screen gui in startergui that is called "Shop_GUI" Mathilinium 112 — 2y
0
yes legobuddie1 0 — 2y

Answer this question