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

Why is this script not working?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I don't understand why this script is not working, nor do I understand the error that it gives me. Every time I test, it says "bob is not a valid member of PlayerGui", yet it is clearly there .

Explorer setup

Script:

imageButton2 = script.Parent
imageButton2.Position = UDim2.new(.5, -125, .5, -200)
imageButton2.Size = UDim2.new(0, 250, 0, 37)
imageButton2.Image = "rbxassetid://169465511"
imageButton2.BackgroundTransparency = 1
imageButton2.Visible = false
local imageButton3 = Instance.new("ImageButton")
imageButton3.Parent = script.Parent.Parent
imageButton3.Position = UDim2.new(.5, -75, .5, -3000)
imageButton3.Size = UDim2.new(0, 150, 0, 20)
imageButton3.Image = "rbxassetid://169465511"
imageButton3.BackgroundTransparency = 1
imageButton3.Visible = false
local imageButton4 = Instance.new("ImageButton")
imageButton4.Parent = script.Parent.Parent
imageButton4.Position = UDim2.new(.5, -75, .5, -50)
imageButton4.Size = UDim2.new(0, 150, 0, 20)
imageButton4.Image = "rbxassetid://169465511"
imageButton4.BackgroundTransparency = 1
imageButton4.Visible = false

local previousbutton2 = script.Parent.Parent.Parent.bob.ImageButton2
local previousbutton3 = script.Parent.Parent.Parent.bob.ImageButton3
local previousbutton4 = script.Parent.Parent.Parent.bob.ImageButton4

previousbutton3.MouseButton1Click:connect(function()
    imageButton2.Visible = true
    imageButton3.Visible = true
    imageButton4.Visible = true
    previousbutton2.Visible = false
    previousbutton3.Visible = false 
    previousbutton4.Visible = false 

end)

`

1 answer

Log in to vote
1
Answered by 10 years ago

Try using WaitForChild(), it may not have appeared yet in-game.

0
I tried, but it loads instantaneously into the PlayerGui anyways. matto323 5 — 10y
Ad

Answer this question