So, basically this script was supposed to work i assume, the script should've run something every time i hold my mouse's left button and then stop when i release it, but instead when i click once it just runs without stopping, but if you hold it a little longer, it works fine, i don't understand why isn't it working, i hope you can help me.
tool.Equipped:Connect(function() game.ReplicatedStorage.Equip:FireServer() mouse.Icon = "http://www.roblox.com/asset/?id=79658449" TextLabel.Visible = true UIS.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then pressed = true while pressed and tool.Equipped do if Ammo1 <= 0 then pressed = false else Ammo1 = Ammo1 - 1 tool.GunShot:Play() if mouse.Target.Parent:FindFirstChild("Humanoid") then script.Parent.Damage:FireServer(mouse.Target) tool.Enabled = false print("target hit") wait(0.09) tool.Enabled = true else tool.Enabled = false print("miss") wait(0.09) tool.Enabled = true UIS.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then pressed = false