Hello, I’ve made a shooting system that when holding Z it’ll fire shots from your character. The problem is that when you move/press any other key while holding Z it’ll stop shooting. How can I fix this?
https://i.gyazo.com/79a1bea7bae60e836907ad515e9ef5fd.gif
I’ve tried changing the script and switching it around and stuff but it doesn’t seem to work.
local UIS = game:GetService("UserInputService")
local Event = script:WaitForChild("ShootEvent")
local Shooting
UIS.InputBegan:Connect(function(Key,IsTyping)
if IsTyping then return end
Shooting = false
if Key.KeyCode == Enum.KeyCode.Z and Shooting == false then
Shooting = true
while Shooting == true do
if Shooting == false then break end
Event:FireServer()
task.wait(0.1)
end
end
end)
UIS.InputBegan:Connect(function(Key,IsTyping)
if IsTyping then return end
if Key.KeyCode == Enum.KeyCode.Z and Shooting == true then
Shooting = false
end
end)