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

closeButton is not a valid member of ScreenGui ?

Asked by 3 years ago

HI, In the code I made it tells me (line 7) closeButton is not a valid member of ScreenGui "Players.xXDskaCapyXx.PlayerGui.ScreenGui" (xXDskaCapyXx it's me)

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.ScreenGui.Shop.Visible = true

    player.Character.Humanoid.WalkSpeed = 0

end

end

local function closeMenu()

local player = game.Players.LocalPlayer

player.PlayerGui.ScreenGui.Shop.Visible = false

player.Character.HumanoidRootPart.CFrame = 

CFrame.new(close.Position.X,close.Position.Y,close.Position.Z)

player.Character.Humanoid.WalkSpeed = 16

end

open.Touched:Connect(ShopMenu)

closeButton.MouseButton1Click:Connect(closeMenu)

here is the whole code please I need help thank you in advance

0
Try 'local closeButton = frame:WaitForChild("closeButton")'. The likely reason is because the button has not loaded in yet when you are trying to reference it. appxritixn 2235 — 3y
0
Thats probably the case. The script sometimes load before the closebutton does so it runs through all the code before the closebutton is a thing and therefore has an error JustinWe12 723 — 3y

Answer this question