UserInputType
Read about UserInputService first here, InputBegan returns input and gameProcessedEvent. input in your case is not UserInputType but it's just the input Instance. All you have to do is change input == Enum.UserInput.... to input.UserInputType == Enum.UserInput... and it should work.
local UserInput = game:GetService("UserInputService")
local function InputBegan(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
...
Spacebar and other keys
To use Keys, you need to use Input.KeyCode which is key that the user pressed. All the key names are here. Space would be 32 or Enum.KeyCode.Space. The reason why you can use number is because 32 is number for Space in Ascii characters, here is an image of ascii characters. Code Example:
local function InputBegan(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.Space then
...
local function InputBegan(input, gameProcessed)
if input.KeyCode == '32' then
Both of these will run when spacebar is clicked.
Sources
UserInputType
KeyCode
InputBegan
UserInputService
Ascii Table
1 comment
You are using a deprecated method for detecting if the player has clicked there mouse. You are recommended by Roblox to use UserInputService!