Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i fix the error of "ShopUI is not a valid member of PlayerGui"?

Hello, im trying to call out to a ShopUI in PlayerGui from a local script from another UI Button in StarterGui, and i keep getting the error of "ShopUI is not a valid member of PlayerGui" which happens on line 3 where I define where the UI i want to tween is. I've tried using :WaitForChild() and reformatting things around in my script and nothing seems to work. I'm running this from a LocalScript, and as far as i know, LocalScripts can access the LocalPlayers PlayerGui. My script can be found below.

local IconButton = script.Parent
local IconImage = script.Parent.IconImage
local ShopUI = game.Players.LocalPlayer.PlayerGui.ShopUI.Shop
local Debounce = false
local Blur = game.Lighting.ShopUIBlur

IconButton.MouseButton1Down:Connect(function()
	if not Debounce then
		Debounce = true
		IconButton.ImageTransparency = 0
		IconButton.ImageColor3 = Color3.fromRGB(255, 255, 255)
		IconImage.ImageColor3 = Color3.fromRGB(0, 0, 0)
		ShopUI:TweenPosition(
			UDim2.new(0.5, 0,0.5, 0),
			"Out",
			"Sine",
			0.8,
			true
		)
		
		for i = 0,24,1 do
	         wait()
	         Blur.Size = i
	     end
	else
		Debounce = false
		IconButton.ImageTransparency = 0.5
		IconButton.ImageColor3 = Color3.fromRGB(0, 0, 0)
		IconImage.ImageColor3 = Color3.fromRGB(255, 255, 255)
		ShopUI:TweenPosition(
			UDim2.new(0.5, 0,-0.9, 0),
			"Out",
			"Sine",
			0.8,
			true
		)
		
		for i = 24,0,-1 do
                wait()
                Blur.Size = i
            end
        end
	end)

If anyone could help me with this, it would be nice.

2 comments

0

Is ShopUI inside of a screengui or is it just right inside StarterGui? Once the game is loaded look under players, under you, and under playergui and see if "ShopUI" spelt like that is there.

0

yeah it is

1 answer

✓ Accepted answer

You just need to make the script wait for it to load by using :WaitForChild

local IconButton = script.Parent
local IconImage = script.Parent.IconImage
local ShopUI = game.Players.LocalPlayer.PlayerGui:WaitForChild("ShopUI").Shop
local Debounce = false
local Blur = game.Lighting.ShopUIBlur

IconButton.MouseButton1Down:Connect(function()
    if not Debounce then
        Debounce = true
        IconButton.ImageTransparency = 0
        IconButton.ImageColor3 = Color3.fromRGB(255, 255, 255)
        IconImage.ImageColor3 = Color3.fromRGB(0, 0, 0)
        ShopUI:TweenPosition(
            UDim2.new(0.5, 0,0.5, 0),
            "Out",
            "Sine",
            0.8,
            true
        )

        for i = 0,24,1 do
             wait()
             Blur.Size = i
         end
    else
        Debounce = false
        IconButton.ImageTransparency = 0.5
        IconButton.ImageColor3 = Color3.fromRGB(0, 0, 0)
        IconImage.ImageColor3 = Color3.fromRGB(255, 255, 255)
        ShopUI:TweenPosition(
            UDim2.new(0.5, 0,-0.9, 0),
            "Out",
            "Sine",
            0.8,
            true
        )

        for i = 24,0,-1 do
                wait()
                Blur.Size = i
            end
        end
    end)

This discussion is preserved as it was. New answers, comments, and votes are closed.