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

Keypress Event not working... What is my error? (updated)

Asked by 3 years ago
Edited 3 years ago

My old question was answered but it still wouldn't work. The script the person who answered my question gave me had some errors so I changed it but now I "Attempted to call a nil value." Can anyone point out what my error was please? Please check the script below. Thank you for your time.

Script:

    local userInputService = game:GetService("UserInputService")
    local Inventory = script.Parent:GetChildren("Inventory")

    userInputService.InputBegan:Connect(function(input)
        if input.KeyCode == Enum.KeyCode.E then
            Inventory.Visible = true
            Inventory:TweenPosition{
            UDim2.new(0.068, 0, 0.077, 0), 
            Enum.EasingDirection.Out,
            Enum.EasingStyle.Quad,
            0.5,
            false
        }
    end
end)
0
does inventory exist with how you find it?? if not, thats what the script is telling you.... also the script looks like you cut out some things, i suggest you give the full script so we can make the best of analysis speedyfox66 237 — 3y
0
Try replacing line 2 with local Inventory = script.Parent:WaitForChild("Inventory") LeedleLeeRocket 1257 — 3y
0
The Inventory exists inside the ScreenGui FilipinoWrld 22 — 3y

Answer this question