How to transfer data from LocalScript and ServerScript to Server?

I know about RemoteEvents, but is there a way to send a click event from a LocalScript to a ServerScript then to the Server?

I don’t want exploiters changing the firing rate on a firearm (MP5).

Here is my local script:

firearm.Equipped:Connect(function()
    mouse.Button1Down:Connect(function()
        shooting = true
        while shooting do
            -- Maybe send information that mouse is held down to a Server script?
        end
    end)
end)

Here is my Server Script:

local magazineAmmo = 30
local availableAmmo = 200
local firingRate = 800

-- If mouse is held down, use the firingRate to determine how many bullets will fire

image

I kind of did that, however, the user can put wait(0.1) and shoot very fast.

For example:

firearm.Equipped:Connect(function()
    mouse.Button1Down:Connect(function()
        shooting = true
        while shooting do
            wait(0.1) -- VERY FAST SHOOTING
            RemoteEvent:FireServer("MP5") -- weapon's name as a string
        end
    end)
end)

-- Server Script
local magazineAmmo = 30
local availableAmmo = 200
local firingRate = 800

RemoteEvent.OnServerEvent:Connect(function(player, WeaponName)
	if WeaponName == "MP5" then
		wait(0.5)
                -- SHOOT
	end
end)

before helping i suggest in your localscript turning mouse.Button1Down to UIS instead

add server side cooldown so even if they do fire event they can’t fire the wepon

Use Remote functions