Potential improvements to my server side weapon fired method?

I’m looking for both potential security vulnerabilities (There are probably a lot) and efficiency improvements. If you have suggestions, I would love to hear them! This is the server side receive. The biggest exploit in my game right now is rate of fire increases, and with burst weapons, detecting spammed requests presents a bit of a challenge.

functions.FireWeapon = function(client,receive)
		--FireAllClientsWithException to create audio
		if receive.Source and receive.BulletDir and clientdata.Cache[client.UserId] then
			if clientdata.Cache[client.UserId].EquippedWeapon then
				network:FireAllClientsWithException(client, {Function = "PlayerFiredWeapon", Player=client, Weapon = clientdata.Cache[client.UserId].EquippedWeapon, Source = receive.Source, Direction = receive.BulletDir})
				local weaponData = require(game.ReplicatedStorage.Weapons:FindFirstChild(clientdata.Cache[client.UserId].EquippedWeapon).Information)
				if receive.Hit and clientdata.Cache[client.UserId].IsDeployed == true then
					--// If the last shot was a headshot, set it to be so in the cache. and vice versa.
					clientdata.Cache[client.UserId].LastShotHeadshot = (receive.Hit.Name == "Head" or receive.Hit.Name == "HatHandle")
					local humanoid = nil
					if receive.Hit.Parent then
						humanoid = receive.Hit.Parent:FindFirstChild("Humanoid")
						if not humanoid then
							humanoid = receive.Hit.Parent.Parent:FindFirstChild("Humanoid")
						end
					end
					if humanoid then
						if game.Players:GetPlayerFromCharacter(humanoid.Parent) then
							local attackerState = functions.IsProtected(client)
							local defenderState = functions.IsProtected(game.Players:GetPlayerFromCharacter(humanoid.Parent))
							if attackerState[1] == defenderState[1] and attackerState[2] == defenderState[2] then
								if gamemode.CheckTeamByPlayer(game.Players:GetPlayerFromCharacter(humanoid.Parent)) ~= gamemode.CheckTeamByPlayer(client) or gamemode.CurrentGame.Teamkill then
									if clientdata.Cache[game.Players:GetPlayerFromCharacter(humanoid.Parent).UserId].IsDeployed == true then
										local blood = game.ReplicatedStorage.Effects.Blood:Clone()
										blood.Parent = receive.Hit
										if receive.Hit.Name == "Head" or receive.Hit.Name == "HatHandle" then
											humanoid:TakeDamage(weaponData.Stats.Damage * 2)
										else
											humanoid:TakeDamage(weaponData.Stats.Damage)
										end
										network:FireClient(game.Players:GetPlayerFromCharacter(humanoid.Parent),{
											['Function'] 	= "TakeDamage",
											['Attacker']	= client,
											['ShotPosition']= client.Character.HumanoidRootPart.Position
										})
										if clientdata.Cache[game.Players:GetPlayerFromCharacter(humanoid.Parent).UserId].LifeDamage[client.UserId] then
											clientdata.Cache[game.Players:GetPlayerFromCharacter(humanoid.Parent).UserId].LifeDamage[client.UserId] = {clientdata.Cache[game.Players:GetPlayerFromCharacter(humanoid.Parent).UserId].LifeDamage[client.UserId][1] + 10,tick()}
										else
											clientdata.Cache[game.Players:GetPlayerFromCharacter(humanoid.Parent).UserId].LifeDamage[client.UserId] = {15,tick()}
										end
										wait(.2)
										blood:Destroy()
									end
								end
							end
						else
							humanoid:TakeDamage(weaponData.Stats.Damage)
						end
					elseif receive.Hit.Name == "Glass" then
						if receive.Hit.Transparency ~= 1 then
							local effect = game.ReplicatedStorage.Effects.GlassShatter:Clone()
							effect.Parent = receive.Hit
							receive.Hit.Transparency = 1
							receive.Hit.CanCollide = false
							wait(.2)
							effect.Enabled = false
							wait(1.5)
							receive.Hit:Destroy()
						end
					end
				end
			end
		end
	end
2 Likes