The problem is you are checking if the player is has pressed down on their left mousebutton. But at the same time, you are also checking if the player has pressed down on their space key. When the player presses space or any key on the keyboard for that matter, the property UserInputType’s Value changes to Keyboard. And when you press a mouse button, the UserInputType’s value changes to Mouse. Do you see the issue?
elseif input.UserInputType == Enum.UserInputType.MouseButton1 and UIS:IsKeyDown("Space") then
To go a little more in depth, when UserInputService Receives an Input, it can receive both Keyboard and Mouse inputs. But it will only receive one input at time. That first input being the first key or button that gets pressed. Here’s some code to make it easier to understand:
UIS.InputBegan:Connect(function(Input, IsTyping)
local InputType = Input.UserInputType
if not IsTyping then
if InputType == Enum.UserInputType.MouseButton1 then
print('Clicked')
elseif InputType == Enum.UserInputType.Keyboard then
print('Pressed Key')
end
end
end)
Now, if i press both the space key on my keyboard and my left mouse button. It will print what registered first, so let’s say if i pressed the space key some few milliseconds before i pressed my left mouse button. Then it will print:

And vice versa.
So to fix this issue, you would have to do something like this:
local UIS = game:GetService("UserInputService")
local SpacePressed = false
UIS.InputBegan:Connect(function(Input, IsTyping)
local InputType = Input.UserInputType
if not IsTyping then
if InputType == Enum.UserInputType.Keyboard then
if Input.KeyCode == Enum.KeyCode.Space then
SpacePressed = true
else
SpacePressed = false
end
elseif InputType == Enum.UserInputType.MouseButton1 and SpacePressed then
print("Pressed Space: ".. tostring(SpacePressed), "InputType: ".. InputType.Name)
SpacePressed = false
end
end
end)
This is a rather simple fix, but it’s a basic example of a possible solution for your problem. Keep in mind, this isn’t supposed to replace your entire code, the purpose of this code snippet is just to show how to check for two input presses “at once”.
If you have any questions or problems just reply and I’ll make sure to reply back. :)!