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

Got problem, cant access another GUI from a script, can someone help?

Asked by 5 years ago
Edited 5 years ago

So uh i got a problem, roblox keeps telling me that there is error in line.

01local plr = game.Players.LocalPlayer
02local object = script.Parent.Parent
03-- local Menu = plr.PlayerGui.btn == error
04local button = script.Parent
05local toggle = false
06 
07object.AnchorPoint = Vector2.new(0.5, 0.5)
08object.Position = UDim2.new(0.5, 0, 0.5, 0)
09 
10local function onButtonActivated()
11    if toggle == false then
12        object:TweenSize(UDim2.new(0, 0, 0, 0))
13        script.Parent:TweenSize(UDim2.new(0, 0, 0, 0))
14        Menu:TweenPosition(UDim2.new(0, 0,0.887, 0))
15        wait(1)
View all 25 lines...

so i tried all the ways, script.Parent, but it always was saying "btn is not a valid member of PlayerGui" but if you look there musn't be any problems? screenGUI named btn

1 answer

Log in to vote
0
Answered by 5 years ago

The ScreenGui wasn't having time to load. Use local menu = plr.PlayerGui:WaitForChild("btn") to yield until it does load.

Ad

Answer this question