I am trying to create a gun which shoots when “Z” is pressed, as the mouse-button will be used for other functions. The mouse part is working, but nothing happens when I press Z, because:
UserInputType is not a valid member of Mouse “Instance”
The bullet will be flying in the direction of the cursor, which is why I still need the mouse in my function. Is there a better (functional) way to do this?
This is my script which fires the bullet:
Blockquote
gun.Equipped:Connect(function(input,gameProcessed,mouse)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
local keycode = input.KeyCode
if keycode == Enum.KeyCode.z then
if gun.Ammo.Value > 0 then
remoteEventMusket:FireServer(gun.Handle.Position,mouse.Hit.p)
print(“musket fired”)
gun_shot:Play()
gun.Ammo.Value = gun.Ammo.Value - 1
else
gun_empty:Play()
end
end
wait(4)
gun.Ammo.Value = 2
end
end
end)