Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

1 comment

0

Thanks for the help man, I knew it was something stupid.

This discussion is preserved as it was. New answers, comments, and votes are closed.