local Player = game.Players.LocalPlayer local character = Player.Character local Mouse = Player:GetMouse() local debounce = true Mouse.Button1Down:Connect(function() debounce = false while true do wait() print('gg') if debounce == true then return end end end) Mouse.Button1Up:Connect(function() if debounce == false then debounce = true end end)
This is my code and im trying to print when the mouse button is down just like a automatic gun in phantom forces shooting repedeatly im trying to print repedeatly it works but im just wondering if this is how most people do it and if its efficient
It's not an inefficient algorithm for shooting. Though, I should note that it would be preferable to use this code within a framework for your game using methods such as OOP in order to match the specifications of each weapon. In addition to that, the debounce would also be specific to each weapon and each would have their own requirements to shoot.
Closed as Primarily Opinion-Based by User#24403
This question has been closed because it is a discussion about a topic focused on diverse opinions, which isn't a good fit for our Q&A format.
Why was this question closed?