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

Problems with GUI and Script?

Asked by
OKRPLAY 25
8 years ago

Hello,

i'm making a gui that pops out. I have following code:

local frame = script.Parent


draussen = script.Parent.draussen

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        print("opening")

        if draussen == true then

-- "draussen" is a bool value that says if the gui is out or not(true = out, false = in)

            frame:TweenPosition(UDim2.new(1, 0, 0.75, 0), 'Out', 'Bounce', 0.5)
            draussen = false


        else

            frame:TweenPosition(UDim2.new(1, -500 ,0.75, 0), 'Out', 'Bounce', 0.5)
            draussen = true

        end


    end
end

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.Return)

If i press Enter in Studio, it pops out. If i join the Game and press Enter, it says following:

Starting script
draussen is not a valid member of Frame
Script 'Players.OKRPLAY.Playergui.stempelgui.Frame.stempel.rein_raus', Line 4
Stack End

Why is this happening?

0
Use a :WaitForChild() TheHospitalDev 1134 — 8y

Answer this question