lets say i have an automatic weapon and i want it to shoot every 0.1s. what is the best way to receive the player’s mouse location?
i could send a remote event every 0.1s, i could make a remote function to receive the mouse location every 0.2s the weapon is active, but are there any other methods?
that seems horribly unoptimized and i’m sure there’s a better way… is there?
since it’s an automatic weapon you can send a remote event when the player “Holds” the button indicating start then the server will fire each 0.1s until he gets an ended signal
not a good code just for demonstration
local active = false
FireStart.OnServerEvent:Connect(function()
active = true
while active and thereIsAmmo do
-- FIRE Logic
task.wait()
end
end)
FireEnd.OnServerEvent:Connect(function()
active = false
end)
and you can send another remote event to the server to update the mouse position but check on the client if the new mouse position isn’t the same as the old one before sending the event
there may be better methods than this but that is what I came up with
aren’t they unreliable? i haven’t personally had enough experience around them to know for sure. i tend to use them for effects or things that don’t affect gameplay. should i be using them for stuff like this?