So uh i got a problem, roblox keeps telling me that there is error in line.
local plr = game.Players.LocalPlayer local object = script.Parent.Parent -- local Menu = plr.PlayerGui.btn == error local button = script.Parent local toggle = false object.AnchorPoint = Vector2.new(0.5, 0.5) object.Position = UDim2.new(0.5, 0, 0.5, 0) local function onButtonActivated() if toggle == false then object:TweenSize(UDim2.new(0, 0, 0, 0)) script.Parent:TweenSize(UDim2.new(0, 0, 0, 0)) Menu:TweenPosition(UDim2.new(0, 0,0.887, 0)) wait(1) object.Visible = false script.Parent.Visible = false toggle = true else wait(1) toggle = false end end button.Activated:Connect(onButtonActivated)
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
The ScreenGui wasn't having time to load. Use local menu = plr.PlayerGui:WaitForChild("btn")
to yield until it does load.