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

UserInputService is not a valid member of InputObject "InputObject" fix?

Asked by 3 years ago
Edited 3 years ago

Hello, I'm a beginner programmer and I encountered this error while testing and don't understand what's the problem. Probably it's a stupid error but I don't know how to fix it since it's one of my first games. Can someone tell me how to fix this, or maybe if there's something else I did wrong?

This is my first post here by the way.

Here's the script:

local userInput = game:GetService("UserInputService")
local Players = game:GetService("Players")

--local jumpHeight = 40
--local jumpHeightNormal = 20

local player = Players.LocalPlayer

local function highJump(input, gameProcessed)
    if not gameProcessed then
        if input.UserInputService == Enum.UserInputType.Keyboard then
            local keycode = input.KeyCode
            if keycode == Enum.KeyCode.LeftControl then
                --player.Character.Humanoid.JumpPower = jumpHeight
                print("Activated") 
            end
        end
    end
end

local function normalJump(input, gameProcessed)
    ``if not gameProcessed then  --error line``
        if input.UserInputService == Enum.UserInputType.Keyboard then
            local keycode = input.KeyCode
            if keycode == Enum.KeyCode.LeftControl then
                --player.Character.Humanoid.JumpPower = jumpHeightNormal
                print("Deactivated")
            end
        end
    end
end

userInput.InputBegan:Connect(highJump)
userInput.InputEnded:Connect(normalJump)

Thanks in advance! :)

1 answer

Log in to vote
0
Answered by 3 years ago

Services are not located inside of inputs. You get UserInputService using game:GetService("UserInputService"), which you've already done because that's how you get the player's input in the first place.

I'm guessing this is a typo that you made on line 11 and 23. Change if input.UserInputService == Enum.UserInputType.Keyboard to if input.UserInputType == Enum.UserInputType.Keyboard

0
Thanks for the help man, I knew it was something stupid. ShadowGamer2319 2 — 3y
Ad

Answer this question