-- Create the player input event handler

Players.PlayerInputBegan:Connect(function(player, input)
	-- Check if the player is pressing the fire button
	if input.KeyCode == Enum.KeyCode.E then
		-- Shoot at the nearest enemy
		local nearestEnemy = nil
		local nearestDistance = math.huge
		for _, enemy in pairs(gameState.enemies) do
			local distance = (enemy.Position - player.Character.HumanoidRootPart.Position).Magnitude
			if distance < nearestDistance then
				nearestEnemy = enemy
				nearestDistance = distance
			end
		end

		if nearestEnemy ~= nil then
			-- Shoot at the enemy
			nearestEnemy:TakeDamage(10)
		end
	end
end)
